You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Michel Jansen <Mi...@Web-ICT.com> on 2010/05/13 01:21:22 UTC

Cache Control

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

Posted by André Warnier <aw...@ice-sa.com>.
Perrin Harkins wrote:
> [forgot to CC the list]
> 
> On Thu, May 13, 2010 at 3:56 AM, Michel Jansen
> <Mi...@web-ict.com> 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.


Re: Cache Control

Posted by Perrin Harkins <pe...@elem.com>.
[forgot to CC the list]

On Thu, May 13, 2010 at 3:56 AM, Michel Jansen
<Mi...@web-ict.com> 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.

- Perrin

Re: Cache Control

Posted by Perrin Harkins <pe...@elem.com>.
On Wed, May 12, 2010 at 7:21 PM, Michel Jansen
<Mi...@web-ict.com> 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