changeset 1542:dc4c61363d0a

Add timestamps to 'app.js' filenames, to prevent inappropriate caching by browsers
author Adam Chlipala <adam@chlipala.net>
date Fri, 19 Aug 2011 08:59:01 -0400 (2011-08-19)
parents 94ef0b07066a
children 6f046b4bad24
files src/cjr_print.sml tests/appjs.ur
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/cjr_print.sml	Mon Aug 15 12:33:28 2011 -0400
+++ b/src/cjr_print.sml	Fri Aug 19 08:59:01 2011 -0400
@@ -2637,6 +2637,10 @@
                               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 @@
                                                 let
                                                     val scripts =
                                                         "<script type=\\\"text/javascript\\\" src=\\\""
-                                                        ^ OS.Path.joinDirFile {dir = Settings.getUrlPrefix (),
-                                                                               file = "app.js"}
+                                                        ^ app_js
                                                         ^ "\\\"></script>\\n"
                                                 in
                                                     foldl (fn (x, scripts) =>
@@ -3117,8 +3120,7 @@
              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\");",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/appjs.ur	Fri Aug 19 08:59:01 2011 -0400
@@ -0,0 +1,5 @@
+fun id n = if n = 0 then 0 else 1 + id (n - 1)
+
+fun main () : transaction page = return <xml><body>
+  <button onclick={alert (show (id 3))}/>
+</body></xml>