summaryrefslogtreecommitdiff
path: root/src/cjr_print.sml
diff options
context:
space:
mode:
Diffstat (limited to 'src/cjr_print.sml')
-rw-r--r--src/cjr_print.sml30
1 files changed, 28 insertions, 2 deletions
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,