diff options
-rw-r--r-- | perllib/Page.pm | 19 | ||||
-rwxr-xr-x | web/about.cgi | 6 | ||||
-rwxr-xr-x | web/faq.cgi | 9 | ||||
-rwxr-xr-x | web/reports.cgi | 4 |
4 files changed, 25 insertions, 13 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm index c1cc7c281..bd6d9253c 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: Page.pm,v 1.121 2008-10-15 16:14:57 francis Exp $ +# $Id: Page.pm,v 1.122 2008-10-15 22:07:25 matthew Exp $ # package Page; @@ -16,6 +16,7 @@ use Carp; use mySociety::CGIFast qw(-no_xhtml); use Error qw(:try); use File::Slurp; +use HTTP::Date; use Image::Magick; use LWP::Simple; use Digest::MD5 qw(md5_hex); @@ -41,12 +42,16 @@ BEGIN { mySociety::Config::set_file("$FindBin::Bin/../conf/general"); } +my $lastmodified; + sub do_fastcgi { - my $func = shift; + my ($func, $lm) = @_; try { my $W = new mySociety::WatchUpdate(); - while (my $q = new mySociety::CGIFast()) { + while (my $q = new mySociety::Web()) { + next if $lm && $q->Maybe304($lm); + $lastmodified = $lm; microsite($q); &$func($q); dbh()->rollback() if $mySociety::DBHandle::conf_ok; @@ -107,7 +112,7 @@ Return HTML for the top of the page, given PARAMs (TITLE is required). sub header ($%) { my ($q, %params) = @_; - my %permitted_params = map { $_ => 1 } qw(title rss js); + my %permitted_params = map { $_ => 1 } qw(title rss js expires lastmodified); foreach (keys %params) { croak "bad parameter '$_'" if (!exists($permitted_params{$_})); } @@ -118,7 +123,11 @@ sub header ($%) { my $home = !$title && $ENV{SCRIPT_NAME} eq '/index.cgi' && !$ENV{QUERY_STRING}; - print $q->header(-charset => 'utf-8'); + my %head = (); + $head{-expires} = $params{expires} if $params{expires}; + $head{'-last-modified'} = time2str($params{lastmodified}) if $params{lastmodified}; + $head{'-last-modified'} = time2str($lastmodified) if $lastmodified; + print $q->header(%head); my $html; if ($q->{site} eq 'scambs') { diff --git a/web/about.cgi b/web/about.cgi index c0e92e54b..e660bd8d1 100755 --- a/web/about.cgi +++ b/web/about.cgi @@ -6,11 +6,13 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: about.cgi,v 1.7 2008-10-13 14:06:44 matthew Exp $ +# $Id: about.cgi,v 1.8 2008-10-15 22:07:26 matthew Exp $ use strict; use Standard -db; +my $lastmodified = (stat $0)[9]; + # Main code for index.cgi sub main { my $q = shift; @@ -26,5 +28,5 @@ England. We also work in partnership with other charities across the UK.</p> ABOUTUS print Page::footer($q); } -Page::do_fastcgi(\&main); +Page::do_fastcgi(\&main, $lastmodified); diff --git a/web/faq.cgi b/web/faq.cgi index 0219ccb16..fb9c86636 100755 --- a/web/faq.cgi +++ b/web/faq.cgi @@ -6,15 +6,16 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: faq.cgi,v 1.36 2008-10-14 09:53:30 matthew Exp $ +# $Id: faq.cgi,v 1.37 2008-10-15 22:07:26 matthew Exp $ use strict; use Standard -db; -# Main code for index.cgi +my $lastmodified = (stat $0)[9]; + sub main { my $q = shift; - print Page::header($q, title=>_('FAQ')); + print Page::header($q, title=>_('Frequently Asked Questions')); if ($q->{site} eq 'emptyhomes') { print emptyhomes_faq($q); } else { @@ -22,7 +23,7 @@ sub main { } print Page::footer($q); } -Page::do_fastcgi(\&main); +Page::do_fastcgi(\&main, $lastmodified); sub faq { my $q = shift; diff --git a/web/reports.cgi b/web/reports.cgi index 7a526c1e9..913a1fbaf 100755 --- a/web/reports.cgi +++ b/web/reports.cgi @@ -7,7 +7,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: reports.cgi,v 1.20 2008-09-19 10:24:55 matthew Exp $ +# $Id: reports.cgi,v 1.21 2008-10-15 22:07:26 matthew Exp $ use strict; use Standard; @@ -152,7 +152,7 @@ sub main { my $areas_info = mySociety::MaPit::get_voting_areas_info([keys %councils]); if (!$one_council) { - print Page::header($q, title=>_('Summary reports')); + print Page::header($q, title=>_('Summary reports'), expires=>'+1h'); print $q->p(_('This is a summary of all reports on this site; select a particular council to see the reports sent there.')); my $c = 0; print '<table cellpadding="3" cellspacing="1" border="0">'; |