Next time the browser requests the same page it will add a header to the request: If-Modified-Since: Thu, 20 Jan 2005 07:11:33 GMT
Given such a request usemod still produces the entire response, but my apache server (default) config catches that and converts the response into just: HTTP/1.x 304 Not Modified Date: Wed, 02 Feb 2005 00:58:17 GMT
- which obviously can save a lot of bandwidth. I verified this with the excellent http://livehttpheaders.mozdev.org/ plugin for FireFox?
I hope this will make it into the next version of UseMod. Regards, Lasse Lindgård
Change the GetHttpHeader method to this version:
sub GetHttpHeader {
my ($type) = @_; my $cookie; my $lastmod;
$type = 'text/html' if ($type eq '');
$lastmod = localtime($Section{'ts'});
if (defined($SetCookie{'id'})) {
$cookie = "$CookieName?="
. "rev&" . $SetCookie{'rev'}
. "&id&" . $SetCookie{'id'}
. "&randkey&" . $SetCookie{'randkey'};
$cookie .= ";expires=Fri, 08-Sep-2013 19:48:23 GMT";
if ($HttpCharset ne '') {
return $q->header(-cookie=>$cookie,
-type=>"$type; charset=$HttpCharset", "Last-Modified"=>$lastmod);
}
return $q->header(-cookie=>$cookie, "Last-Modified"=>$lastmod);
}
if ($HttpCharset ne '') {
return $q->header(-type=>"$type; charset=$HttpCharset", "Last-Modified"=>$lastmod);
}
return $q->header(-type=>$type, "Last-Modified"=>$lastmod);
}
NOTE: I havn't done extensive testing on how this works with special pages. It doesn't cache RecentChanges though ...