]> git.sesse.net Git - pr0n/commitdiff
Support caching of the index pages. (Cache invalidation coming soon!)
authorSteinar H. Gunderson <sesse@debian.org>
Mon, 25 Dec 2006 16:25:05 +0000 (17:25 +0100)
committerSteinar H. Gunderson <sesse@debian.org>
Mon, 25 Dec 2006 16:25:05 +0000 (17:25 +0100)
perl/Sesse/pr0n/Index.pm
sql/pr0n.sql

index 5aa3138bd8d5695cc2e087563cafc5ce024cb99b..6e1d237ce4640a4fbac9e5c794d5cb0cc1940b03 100644 (file)
@@ -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);
index 9d1f9374d3bae4e86a9fbd92dfa288d17cfb8c77..583b00f287a3e444cbc8ebf103189af0bb4bf642 100644 (file)
@@ -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.