Mercurial > urweb
comparison src/cjr_print.sml @ 1263:be2ef50780ed
Support HTTP caching of app.js
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 23 May 2010 11:52:13 -0400 |
parents | fd1a49b51db5 |
children | 514be09d5018 |
comparison
equal
deleted
inserted
replaced
1262:003df929ee08 | 1263:be2ef50780ed |
---|---|
2778 newline], | 2778 newline], |
2779 string "}", | 2779 string "}", |
2780 newline] | 2780 newline] |
2781 | 2781 |
2782 val initializers = List.mapPartial (fn (DTask (Initialize, e), _) => SOME e | _ => NONE) ds | 2782 val initializers = List.mapPartial (fn (DTask (Initialize, e), _) => SOME e | _ => NONE) ds |
2783 | |
2784 val now = Time.now () | |
2785 val nowD = Date.fromTimeUniv now | |
2786 val rfcFmt = "%a, %d %b %Y %H:%M:%S" | |
2783 in | 2787 in |
2784 box [string "#include <stdio.h>", | 2788 box [string "#include \"", |
2789 string (OS.Path.joinDirFile {dir = Config.includ, | |
2790 file = "config.h"}), | |
2791 string "\"", | |
2792 newline, | |
2793 string "#include <stdio.h>", | |
2785 newline, | 2794 newline, |
2786 string "#include <stdlib.h>", | 2795 string "#include <stdlib.h>", |
2787 newline, | 2796 newline, |
2788 string "#include <string.h>", | 2797 string "#include <string.h>", |
2789 newline, | 2798 newline, |
2790 string "#include <math.h>", | 2799 string "#include <math.h>", |
2800 newline, | |
2801 string "#include <time.h>", | |
2791 newline, | 2802 newline, |
2792 if hasDb then | 2803 if hasDb then |
2793 box [string ("#include <" ^ #header (Settings.currentDbms ()) ^ ">"), | 2804 box [string ("#include <" ^ #header (Settings.currentDbms ()) ^ ">"), |
2794 newline] | 2805 newline] |
2795 else | 2806 else |
2873 string "if (!strcmp(request, \"", | 2884 string "if (!strcmp(request, \"", |
2874 string (OS.Path.joinDirFile {dir = Settings.getUrlPrefix (), | 2885 string (OS.Path.joinDirFile {dir = Settings.getUrlPrefix (), |
2875 file = "app.js"}), | 2886 file = "app.js"}), |
2876 string "\")) {", | 2887 string "\")) {", |
2877 newline, | 2888 newline, |
2878 box [string "uw_write_header(ctx, \"Content-type: text/javascript\\r\\n\");", | 2889 box [string "uw_Basis_string ims = uw_Basis_requestHeader(ctx, \"If-modified-since\");", |
2890 newline, | |
2891 string ("if (ims && !strcmp(ims, \"" ^ Date.fmt rfcFmt nowD ^ "\")) {"), | |
2892 newline, | |
2893 box [string "uw_clear_headers(ctx);", | |
2894 newline, | |
2895 string "uw_write_header(ctx, \"HTTP/1.1 304 Not Modified\\r\\n\");", | |
2896 newline, | |
2897 string "return;", | |
2898 newline], | |
2899 string "}", | |
2900 newline, | |
2901 newline, | |
2902 string "uw_write_header(ctx, \"Content-type: text/javascript\\r\\n\");", | |
2903 newline, | |
2904 string ("uw_write_header(ctx, \"Last-modified: " ^ Date.fmt rfcFmt nowD ^ "\\r\\n\");"), | |
2879 newline, | 2905 newline, |
2880 string "uw_write(ctx, jslib);", | 2906 string "uw_write(ctx, jslib);", |
2881 newline, | 2907 newline, |
2882 string "return;", | 2908 string "return;", |
2883 newline], | 2909 newline], |