summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2010-05-23 11:52:13 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2010-05-23 11:52:13 -0400
commit2f00e5dc6efb08ae0e7d6540080aaa6a04135707 (patch)
tree485b6a9c7dd4f22fc4a8bf83afabc6250376eade /src
parentb57d77b547ecc51f978e169502e823eded1fca25 (diff)
Support HTTP caching of app.js
Diffstat (limited to 'src')
-rw-r--r--src/c/Makefile.in3
-rw-r--r--src/cjr_print.sml30
2 files changed, 30 insertions, 3 deletions
diff --git a/src/c/Makefile.in b/src/c/Makefile.in
index 98f431f9..59d7b3e4 100644
--- a/src/c/Makefile.in
+++ b/src/c/Makefile.in
@@ -44,6 +44,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -82,7 +83,7 @@ liburweb_fastcgi_la_OBJECTS = $(am_liburweb_fastcgi_la_OBJECTS)
liburweb_http_la_LIBADD =
am_liburweb_http_la_OBJECTS = http.lo
liburweb_http_la_OBJECTS = $(am_liburweb_http_la_OBJECTS)
-DEFAULT_INCLUDES = -I.@am__isrc@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
diff --git a/src/cjr_print.sml b/src/cjr_print.sml
index 06999dec..34936aac 100644
--- a/src/cjr_print.sml
+++ b/src/cjr_print.sml
@@ -2780,8 +2780,17 @@ fun p_file env (ds, ps) =
newline]
val initializers = List.mapPartial (fn (DTask (Initialize, e), _) => SOME e | _ => NONE) ds
+
+ val now = Time.now ()
+ val nowD = Date.fromTimeUniv now
+ val rfcFmt = "%a, %d %b %Y %H:%M:%S"
in
- box [string "#include <stdio.h>",
+ box [string "#include \"",
+ string (OS.Path.joinDirFile {dir = Config.includ,
+ file = "config.h"}),
+ string "\"",
+ newline,
+ string "#include <stdio.h>",
newline,
string "#include <stdlib.h>",
newline,
@@ -2789,6 +2798,8 @@ fun p_file env (ds, ps) =
newline,
string "#include <math.h>",
newline,
+ string "#include <time.h>",
+ newline,
if hasDb then
box [string ("#include <" ^ #header (Settings.currentDbms ()) ^ ">"),
newline]
@@ -2875,7 +2886,22 @@ fun p_file env (ds, ps) =
file = "app.js"}),
string "\")) {",
newline,
- box [string "uw_write_header(ctx, \"Content-type: text/javascript\\r\\n\");",
+ box [string "uw_Basis_string ims = uw_Basis_requestHeader(ctx, \"If-modified-since\");",
+ newline,
+ string ("if (ims && !strcmp(ims, \"" ^ Date.fmt rfcFmt nowD ^ "\")) {"),
+ newline,
+ box [string "uw_clear_headers(ctx);",
+ newline,
+ string "uw_write_header(ctx, \"HTTP/1.1 304 Not Modified\\r\\n\");",
+ newline,
+ string "return;",
+ newline],
+ string "}",
+ newline,
+ newline,
+ string "uw_write_header(ctx, \"Content-type: text/javascript\\r\\n\");",
+ newline,
+ string ("uw_write_header(ctx, \"Last-modified: " ^ Date.fmt rfcFmt nowD ^ "\\r\\n\");"),
newline,
string "uw_write(ctx, jslib);",
newline,