httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Noah Robin <>
Subject Re: RFE: Control of HTTP cache control headers within mod_rewrite rules
Date Tue, 25 Oct 2011 15:10:57 GMT
I ran some tests on this and the following modified version will work:

Header always set Cache-Control max-age=%{CACHE_LIFETIME}e
RewriteRule /example [E=CACHE_LIFETIME:604800]

..however, this still leaves an open question in my mind: How to solve for
the more general case where I want Apache to set the cache control header on
any 301 it sends, even if the 301 was generated within the application
rather than in Apache's configuration. I don't see a way to set an
environment variable based on a response attribute (e.g. r->status). Am I
missing something or would something need to be written to handle this case?


On Sun, Oct 23, 2011 at 5:02 PM, Rowan Collins <>wrote:

> I haven't got a test environment to hand right now, but that looks
> promising - I didn't spot the conditional form of Header directive; clearly
> I should have read the page more carefully. ;)
> I'm not sure if directive order would matter, but in principle maybe
> something like this would work:
> Header set Cache-Control max-age=%{CACHE_LIFETIME}e env=CACHE_LIFETIME
> RewriteRule /example [R=302,E=CACHE_LIFETIME:**604800]
> I'll have to play around, and let you know how I get on - thanks for the
> tip.
> Regards,
> Rowan

View raw message