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