You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Damon Green <da...@gmail.com> on 2011/05/10 13:34:23 UTC

[users@httpd] 301 not being cached

Hi Folks,
I have an issue with mod_cache, it refuses to cache redirects (301) and
insists on cacheing 404 error responses, so really two issues.

I'm using Apache 2.2.17 and the mod_cache/mod_disk_cache from Apache 2.3
which serves stale content from its disk cache when the Tomcat is
unavailable. (patched version from the devs)

Trawling the list archives and docos imply that 404 responses should not be
cached, and that 30x responses should be, but the behaviour I'm seeing is
the opposite of that.

I need 301 redirects to remain working (from the cache) when we disable
Tomcat.

To test this Ive created a rewrite rule in the Apache conf:

RewriteRule ^/damon/(.*)    http://www.slashdot.org [R=301,L]

Then cleared the cache, hit a page in /damon/, got redirected, nothing
created in the disk cache.
any 200 or 404 however creates files in the cache.



http://httpd.apache.org/docs/2.2/caching.html

# The response must have a HTTP status code of 200, 203, 300, 301 or 410.

This is largely a function 13.4 in the RFC:

   A response received with a status code of 200, 203, 206, 300, 301 or
   410 MAY be stored by a cache and used in reply to a subsequent
   request, subject to the expiration mechanism, unless a cache-control
   directive prohibits caching. However, a cache that does not support
   the Range and Content-Range headers MUST NOT cache 206 (Partial
   Content) responses.


Any advice or ideas gratefully received.

Regards,
Damon Green.


--