(* COCANWIKI scripts. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. * $Id: cgi_expires.ml,v 1.2 2004/09/07 14:58:34 rich Exp $ *) 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)))