1 (* COCANWIKI - a wiki written in Objective CAML.
2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: cgi_expires.ml,v 1.3 2004/09/09 12:21:22 rich Exp $
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
30 (* This library should eventually be integrated with mod_caml. XXX *)
34 * All content on wiki sites is dynamic, but we try to make it look static
35 * for users and search engines. We have 4 types of 'Expires' headers that
39 * Send an expiry header in the past (theoretically removing content from
42 * Send a short expiry header (now + 5 minutes). This should be used for
45 * Send a medium-term expiry header (now + 24 hours). This should be used
46 * for all "static" content.
48 * Send a very long expiry header (now + 2 years). This should be used for
49 * content which really never will change.
51 let expires_past, expires_short, expires_medium, expires_long =
53 let t = Unix.time () in
54 let tm = Unix.gmtime (t +. float offset) in
55 sprintf "%s, %02d %s %04d %02d:%02d:%02d GMT"
56 (short_weekday tm.Unix.tm_wday)
58 (short_month (tm.Unix.tm_mon + 1))
59 (tm.Unix.tm_year + 1900)
64 let mins m = m * 60 in
65 let days d = d * 86400 in
66 (fun () -> make (mins (-5))),
67 (fun () -> make (mins 5)),
68 (fun () -> make (days 1)),
69 (fun () -> make (days (365*2)))