Skip to content

Commit

Permalink
caching stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
pudge committed Mar 2, 2007
1 parent 092e6f7 commit b0415f4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Slash/Custom/ApacheCompress/ApacheCompress.pm
Expand Up @@ -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]+)/;

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b0415f4

Please sign in to comment.