2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: cgi_expires.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
15 (* This library should eventually be integrated with mod_caml. XXX *)
19 * All content on wiki sites is dynamic, but we try to make it look static
20 * for users and search engines. We have 4 types of 'Expires' headers that
24 * Send an expiry header in the past (theoretically removing content from
27 * Send a short expiry header (now + 5 minutes). This should be used for
30 * Send a medium-term expiry header (now + 24 hours). This should be used
31 * for all "static" content.
33 * Send a very long expiry header (now + 2 years). This should be used for
34 * content which really never will change.
36 let expires_past, expires_short, expires_medium, expires_long =
38 let t = Unix.time () in
39 let tm = Unix.gmtime (t +. float offset) in
40 sprintf "%s, %02d %s %04d %02d:%02d:%02d GMT"
41 (short_weekday tm.Unix.tm_wday)
43 (short_month (tm.Unix.tm_mon + 1))
44 (tm.Unix.tm_year + 1900)
49 let mins m = m * 60 in
50 let days d = d * 86400 in
51 (fun () -> make (mins (-5))),
52 (fun () -> make (mins 5)),
53 (fun () -> make (days 1)),
54 (fun () -> make (days (365*2)))