Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

I have trying out the No Cache and Expires but no work

by Anonymous Monk
on Jun 07, 2001 at 07:29 UTC ( #86462=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

# if using to generate output try: print $query->header( -type => 'text/html', -expires => '-1d', -Pragma => 'no-cache', -Cache-control => 'no-cache'); I have try up the code but problem is it still loading the page when i press the back button. The page only expired when that particular page haven't finish 100% loaded and i press other link, then i press the back button the expired page then only will show. Else the page 100% finish loaded then click to another webpage link and i press back, the page didn't expires. Anyone Have suggestion can please help me. thank you
  • Comment on I have trying out the No Cache and Expires but no work

Replies are listed 'Best First'.
Re: I have trying out the No Cache and Expires but no work
by tinman (Curate) on Jun 07, 2001 at 07:43 UTC

    For a really good site that deals with the issues that you have, try Web Caching.

    I would probably tell you to use the tools on that site to check if your cache control headers are compliant... Some browsers, unfortunately, choose to ignore certain headers (as do some proxy servers).. so it may not be a content but rather a browser issue...

    One thing: I'm not sure if the Expires header is valid... see here for more details..


      Good post. The expires header requires a valid date if you output it yourself ie:

      Expires: Fri, 30 Oct 1998 14:19:41 GMT

      With however, a variety of options (including -'1d')are allowed when you pass values to it, presumably these are converted into a time in GMT - I have never bothered to check. If you send invalid date values in an HTTP expires header (ie 'now' or '0') it is interpreted as being in the past so has the desired effect anyway.


Re: I have trying out the No Cache and Expires but no work
by lestrrat (Deacon) on Jun 07, 2001 at 11:40 UTC

    From what I know, at least Netscape ignores the expires header. HOWEVER, most HTTP caching program/appliances will honor the value

    That doesn't mean that the page will be reloaded if you have a proxy cache in between your browser and the server, for it's the browser that actually determines if it should verify with the server ( or the proxy cache ) if the content has expired

    The fail safe way is this: You need to use the META tag in the HTML, as in:

    <head> <meta http-equiv="Expires" content="......."> .... </head>

    This will let major browsers know that the content will expire at some known time in the future, thus forcing the browser to reload

    At the same time, you should set the HTTP Expires header, so that if there is a proxy-cache in between the browser and the server, the contents are more likely to be renewed.

    Hope that helps

    P.S., of course, you still may want to telnet to your web server and make sure that it's spitting out the correct headers that you think it's spitting out...

Re: I have trying out the No Cache and Expires but no work
by mattr (Curate) on Jun 07, 2001 at 10:46 UTC
    Are you using Netscape? I have found that while Netscape for the most part honors cookie cancellation directives, Explorer does a very bad job of it. This could be a similar problem..
      He means document expiring, not cookie expiring. AFAIK Internet Explorer s*cks at everything :)

      ... Quidquid perl dictum sit, altum viditur.
Re: I have trying out the No Cache and Expires but no work
by Beatnik (Parson) on Jun 07, 2001 at 10:50 UTC
    I doubt both expires as no-cache are guaranteed to work.

    ... Quidquid perl dictum sit, altum viditur.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://86462]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2020-08-08 00:50 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (51 votes). Check out past polls.