Make the front page cacheable.
authorSteinar H. Gunderson <sesse@debian.org>
Fri, 29 Jun 2007 15:04:37 +0000 (17:04 +0200)
committerSteinar H. Gunderson <sesse@debian.org>
Fri, 29 Jun 2007 15:04:37 +0000 (17:04 +0200)
perl/Sesse/pr0n/Listing.pm

index 02ac273cfac7e7a99157661d0cbdd83c0bcd9033..5e05283a683c4cf557eeb4cb13ce68ed0cdce5fd 100644 (file)
@@ -15,6 +15,18 @@ sub handler {
                        return Apache2::Const::OK;
                }
        }
+       
+       # find the last modification
+       my $ref = $dbh->selectrow_hashref('SELECT EXTRACT(EPOCH FROM last_update) AS last_update FROM events WHERE vhost=? ORDER BY last_update DESC LIMIT 1',
+               undef, $r->get_server_name)
+               or error($r, "Could not any events", 404, "File not found");
+       $r->set_last_modified($ref->{'last_update'});
+       $r->content_type('text/html; charset=utf-8');
+                               
+       # If the client can use cache, do so
+       if ((my $rc = $r->meets_conditions) != Apache2::Const::OK) {
+               return $rc;
+       }
 
 #      my $q = $dbh->prepare('SELECT t1.id,t1.date,t1.name FROM events t1 LEFT JOIN images t2 ON t1.id=t2.event WHERE t1.vhost=? GROUP BY t1.id,t1.date,t1.name ORDER BY COALESCE(MAX(t2.date),\'1970-01-01 00:00:00\'),t1.id') or
 #              dberror($r, "Couldn't list events");
@@ -22,9 +34,7 @@ sub handler {
                or dberror($r, "Couldn't list events");
        $q->execute($r->get_server_name)
                or dberror($r, "Couldn't get events");
-
-       $r->content_type('text/html; charset=utf-8');
-
+       
        Sesse::pr0n::Common::header($r, Sesse::pr0n::Templates::fetch_template($r, 'event-listing'));
        $r->print("    <ul>\n");