2 * Written by Richard W.M. Jones <rich@merjis.com>.
3 * Copyright (C) 2004 Merjis Ltd.
4 * $Id: pagestyle.ml,v 1.1 2004/09/07 10:14:09 rich Exp $
14 let run r (q : cgi) (dbh : Dbi.connection) (hostid, _) _ =
15 let page = q#param "page" in
17 try Some (int_of_string (q#param "version")) with Not_found -> None in
23 let sth = dbh#prepare_cached
24 "select css from pages where hostid = ? and url = ?" in
25 sth#execute [`Int hostid; `String page];
28 let sth = dbh#prepare_cached
29 "select css from pages
30 where hostid = ? and id = ? and
31 (url = ? or url_deleted = ?)" in
32 sth#execute [`Int hostid; `Int version; `String page; `String page];
35 match sth#fetch1 () with
37 | [ `String css ] -> css
38 | _ -> assert false in
40 (* It's crucial, for speed of page delivery and rendering, to have
41 * an expires header for CSS. Even though this means that occasionally
42 * people will need to hit [Shift]+Reload, I'm going to set a
43 * medium-length expiry time on this resource.
45 Table.set (Request.headers_out r) "Expires" (Cgi_expires.expires_medium ());
47 q#header ~content_type:"text/css" ();