From 8ef0c7592d5597750ae272bd2b4e19551b1432db Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 25 Dec 2006 17:25:05 +0100 Subject: [PATCH] Support caching of the index pages. (Cache invalidation coming soon!) --- perl/Sesse/pr0n/Index.pm | 8 +++++++- sql/pr0n.sql | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/perl/Sesse/pr0n/Index.pm b/perl/Sesse/pr0n/Index.pm index 5aa3138..6e1d237 100644 --- a/perl/Sesse/pr0n/Index.pm +++ b/perl/Sesse/pr0n/Index.pm @@ -77,12 +77,18 @@ sub handler { $num = undef; } - my $ref = $dbh->selectrow_hashref('SELECT * FROM events WHERE id=? AND vhost=?', + my $ref = $dbh->selectrow_hashref('SELECT name,date,EXTRACT(EPOCH FROM last_update) AS last_update FROM events WHERE id=? AND vhost=?', undef, $event, $r->get_server_name) or error($r, "Could not find event $event", 404, "File not found"); my $name = $ref->{'name'}; my $date = $ref->{'date'}; + $r->set_last_modified($ref->{'last_update'}); + + # If the client can use cache, do so + if ((my $rc = $r->meets_conditions) != Apache2::Const::OK) { + return $rc; + } # Count the number of selected images. $ref = $dbh->selectrow_hashref("SELECT COUNT(*) AS num_selected FROM images WHERE event=? AND selected=\'t\'", undef, $event); diff --git a/sql/pr0n.sql b/sql/pr0n.sql index 9d1f937..583b00f 100644 --- a/sql/pr0n.sql +++ b/sql/pr0n.sql @@ -2,7 +2,8 @@ CREATE TABLE events ( id character varying NOT NULL PRIMARY KEY, date character varying NOT NULL, name character varying NOT NULL, - vhost character varying NOT NULL + vhost character varying NOT NULL, + last_update timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ); -- In a separate table to avoid deadlocks. -- 2.39.2