views:

48

answers:

1

I have a problem of web pages being cached even though I specify that it should not. Take the simple example :

<html>
<head>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
</head>
<?php
    print date("Y/m/d H:i:s");
?>
</html>

Hitting refresh several times in my browser indicates that this page is not reloaded as the time stays the same. It will eventually refresh if I keep on hitting the refresh button in the browser. Where could this page be cached and how can I avoid it?

I'm using Apache 2.2.15, PHP 5.3.2 on openSuse 11.2, and my testing browser is Firefox 3.5.7 on the same machine.

+1  A: 

Have you tried using the no caching headers? e.g.:

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
zaf
yes, my example didn't show, I fixed it
Marius
A `<meta>` tag is different than an HTTP header, though I'm not sure which takes precedence. Do a `curl -I http://example.com/` from the command line to check HTTP cache headers.
Adam Backstrom
Thanks for explaining. I tried setting the headers, but it also doesn't work. curl -I give :HTTP/1.1 200 OKDate: Thu, 15 Apr 2010 10:07:56 GMTServer: Apache/2.2.15 (Unix) PHP/5.3.2X-Powered-By: PHP/5.3.2Cache-Control: no-cache, must-revalidateExpires: Sat, 26 Jul 1997 05:00:00 GMTContent-Type: text/html
Marius
Try curl or wget and request the page and see if the html changes. If it does then you have some serious browser caching issues. Also, make sure firefox is not working in offline mode ;)
zaf
It works correctly with curl and wget. It definately seems to be a Firefox issue. Firefox is not in offline mode, it does actually refresh if I hit the refresh button 20 times or more. Should I maybe ask this question in a Firefox mailing list?
Marius
Hmmm. Try upgrading/installing it again before you do that.
zaf
Thanks for all the tips. This is definitely a Firefox issue, and as such does not belong here. Starting Firefox in safe mode does not present this problem. I didn't find anything googling, so I'll just try to upgrade. Thanks.
Marius