Cache Control

Cache Control

am 13.05.2010 01:21:22 von Michel Jansen

Hello,

I wrote a mod-perl handler with Apache2::RequestRec and i am trying to
control the caching of the pages. I am using:

$r->no_cache(1);
$r->err_headers_out->set(Pragma => 'no-cache');
$r->content_type('text/html');
$r->print($template->output());

return Apache2::Const::OK;

But the pages are still cached... ;-(

Can someone tell me what i am doing wrong?

Kind Regards,


Michel Jansen

Re: Cache Control

am 13.05.2010 01:59:31 von Perrin Harkins

On Wed, May 12, 2010 at 7:21 PM, Michel Jansen
wrote:
> I wrote a mod-perl handler with Apache2::RequestRec and i am trying to
> control the caching of the pages.

Caching by the browser, or by a proxy server in between? How are you
testing to see if the page is cached?

- Perrin

Re: Cache Control

am 13.05.2010 17:08:54 von Perrin Harkins

[forgot to CC the list]

On Thu, May 13, 2010 at 3:56 AM, Michel Jansen
wrote:
> Tha pages are cached by the browser..

Ok. =A0First, you don't need the err_headers_out call, because no_cache
already does that for you.

I'd suggest checking the headers you're sending with a browser plugin,
LWP, or telnet. =A0If the cache control headers are being sent but the
browser is ignoring them, try setting an Expires header.

- Perrin

Re: Cache Control

am 13.05.2010 17:22:08 von aw

Perrin Harkins wrote:
> [forgot to CC the list]
>
> On Thu, May 13, 2010 at 3:56 AM, Michel Jansen
> wrote:
>> Tha pages are cached by the browser..
>
> Ok. First, you don't need the err_headers_out call, because no_cache
> already does that for you.
>
> I'd suggest checking the headers you're sending with a browser plugin,
> LWP, or telnet. If the cache control headers are being sent but the
> browser is ignoring them, try setting an Expires header.
>
For whatever it may help to say this : in my experience with many
customers and many corporate browsers and web firewalls/proxies, the way
in which browsers and proxies decide to cache or not a given page,
/should/ be clear according to the HTTP RFCs, but is quite unpredictable
in the practice.
This is not a mod_perl issue, nor an Apache issue, not even an issue of
your application, it is just a reality. The best you can do is follow
the RFC, see if it works, and if not tweak your headers in function of
one particular situation. But there is no "universal truth" here.