Bug 34888

Summary: mod_cache doesn't rebuild cache when reloading page
Product: Apache httpd-2 Reporter: Felix <apache>
Component: mod_cacheAssignee: Apache HTTPD Bugs Mailing List <bugs>
Severity: normal CC: vladap
Priority: P2 Keywords: PatchAvailable
Version: 2.0.54   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Attachments: First aid quick and dirty backport (against 2.0.54)

Description Felix 2005-05-12 11:19:24 UTC
We use Debian Sarge with Apache 2.0.54-2 prebuild in the debian repository.

mod_disk_cache config:

CacheRoot /cacheroot
CacheSize 1024
CacheEnable disk /
CacheDirLevels 5
CacheDirLength 3

mod_proxy was disabled for the test.

For this test we used a little testscript (cachetest.cgi):

use CGI;
use strict;
my $cachetime=60;
my $foo=localtime();
print "Expires: ".CGI::expires("+".$cachetime."s","http")."\n";
print "Date: ".CGI::expires(0,"http")."\n";
print "Last-Modified: ".CGI::expires(0,"http")."\n";
print "Cache-Control: max-age=$cachetime\n";
print qq(Content-type: text/html
print qq(

We cleaned up /cacheroot and restart apache.

When we first requested the cgi
lynx http://localhost/cgi-bin/cachetest.cgi

the document was cached. The next requests with lynx resulted in the correctly
cached version. After 60 seconds lynx got an new version and the cache rebuilded
as expected.

So far so good. 

BUT: When we request the cgi with
lynx --reload http://localhost/cgi-bin/cachetest.cgi

we see a non-cached version. Which is correct. But the cache is NOT rebuilded:
The next request with  lynx http://localhost/cgi-bin/cachetest.cgi gets the OLD
content of the cache. The reload of the browser only results in a temporarly way
through the cache to the most recent version. But it don't refresh the cache

This behaviour (which is reproducable with Firefox - but easier and more obvious
with lynx) doesn't seem correct.
Comment 1 Rüdiger Plüm 2005-05-21 23:47:26 UTC
As browsers use different headers for their reload operations we have to
distinguish at least two cases here:

Browser sents the following headers:


Pragma: no-cache
Cache-Control: no-cache

This is the case with lynx --reload and shift reload in Mozilla.


Cache-Control: max-age=0

This is the case when the reload button is pressed in Mozilla.

Regarding 1.

This has been fixed in the trunk by revision 156480. The fixes are
in mod_cache.c and cache_util.c. Before the CACHE_SAVE filter was not
added in this case.
In 2.0.54 the comments in cache_util.c in lines 555 - 558 do not match
the code.

Regarding 2.

This is a regression since 2.0.53 where many fixes to mod_cache have been
backported. It works in 2.0.52. This regression was introduced in cache_util.c
by revisision 105236 and fixed by revision 156401 (trunk).

As far as I understand RFC 2616 both cases (at least 2.) break RFC compliance
of mod_cache. Thus I think the according fixes from the trunk should be

Meanwhile I checked with Felix again and the attached quick and dirty
backport should be some first aid.
Comment 2 Rüdiger Plüm 2005-05-21 23:48:10 UTC
Created attachment 15110 [details]
First aid quick and dirty backport (against 2.0.54)
Comment 3 Paul Querna 2005-12-06 07:42:54 UTC
I believe this issue is fixed in 2.2.0.