From afaf7f27220ccc94b3bb29fb14994040e97b1f4e Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Fri, 19 Aug 2011 08:59:01 -0400 Subject: Add timestamps to 'app.js' filenames, to prevent inappropriate caching by browsers --- src/cjr_print.sml | 10 ++++++---- tests/appjs.ur | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 tests/appjs.ur diff --git a/src/cjr_print.sml b/src/cjr_print.sml index cfe8ee13..159948b3 100644 --- a/src/cjr_print.sml +++ b/src/cjr_print.sml @@ -2637,6 +2637,10 @@ fun p_file env (ds, ps) = newline] end + val timestamp = LargeInt.toString (Time.toMilliseconds (Time.now ())) + val app_js = OS.Path.joinDirFile {dir = Settings.getUrlPrefix (), + file = "app." ^ timestamp ^ ".js"} + fun p_page (ek, s, n, ts, ran, side, tellSig) = let val (ts, defInputs, inputsVar, fields) = @@ -2756,8 +2760,7 @@ fun p_file env (ds, ps) = let val scripts = "\\n" in foldl (fn (x, scripts) => @@ -3117,8 +3120,7 @@ fun p_file env (ds, ps) = string "static void uw_handle(uw_context ctx, char *request) {", newline, string "if (!strcmp(request, \"", - string (OS.Path.joinDirFile {dir = Settings.getUrlPrefix (), - file = "app.js"}), + string app_js, string "\")) {", newline, box [string "uw_Basis_string ims = uw_Basis_requestHeader(ctx, \"If-modified-since\");", diff --git a/tests/appjs.ur b/tests/appjs.ur new file mode 100644 index 00000000..01e9f345 --- /dev/null +++ b/tests/appjs.ur @@ -0,0 +1,5 @@ +fun id n = if n = 0 then 0 else 1 + id (n - 1) + +fun main () : transaction page = return +