Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

caching stuff

  • Loading branch information...
commit b0415f42d8dafce587e6ee08f23c6d169f8e77e3 1 parent 092e6f7
@pudge pudge authored
Showing with 16 additions and 1 deletion.
  1. +16 −1 Slash/Custom/ApacheCompress/ApacheCompress.pm
View
17 Slash/Custom/ApacheCompress/ApacheCompress.pm
@@ -17,8 +17,10 @@ use base 'Apache::Compress';
use vars qw($VERSION);
use Compress::Zlib 1.0;
+use Date::Format;
+use Date::Parse;
use Apache::File;
-use Apache::Constants qw(:common);
+use Apache::Constants qw(:common :http);
($VERSION) = ' $Revision$ ' =~ /\$Revision:\s+([^\s]+)/;
@@ -47,6 +49,19 @@ sub handler {
} else {
my $filename = $r->filename;
return NOT_FOUND unless -e $filename;
+ my @stat = stat(_);
+ my $time = $stat[9];
+
+ if ($r->header_in('If-Modified-Since')) {
+ my $ltime = str2time($r->header_in('If-Modified-Since'));
+ if ($ltime >= $time) {
+ $r->status(HTTP_NOT_MODIFIED);
+ $r->send_http_header;
+ return OK;
+ }
+ }
+
+ $r->header_out('Last-Modified' => time2str("%a, %d %h %Y %X %Z", $time));
$fh = Apache::File->new($filename);
}
unless ($fh) {
Please sign in to comment.
Something went wrong with that request. Please try again.