Forum Moderators: open
I'm having some trouble with browsers caching pages. I don't want them too ;)
The problem is that when one of my dynamic pages gives 'one view' of a page but then I do some stuff and return to the same page, the old 'one view' is still there unless I hit 'reload'.
I'd like it to show the new information of course (without manually hitting reload).
I program PHP so have included these headers at the top of every page:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
But the problem persists. Anyone explain why that is and how the problem might be addressed?
Many thanks
Nick
' stop page caching on the client
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
I have found deleted graphics files being displayed by aol browser for up to 2 hours, no matter what I did about clearing my own cache. Everyone told me I was nuts, that i wasn't clearing my cache properly, etc.
When using a browser integrated with the AOL client software, AOL members make web requests through a set of caching proxy servers. If the servers have a current copy of a requested web object, it will be served to the member directly from the cache server instead of the request going over the Internet to the origin web server. AOL will cache most types of web objects including JavaScript files, HTML, and images.
that's just AOL, but I'd suspect many other web gateways do much the same thing.
Dian
Jim, would this work for all PHP files?
<Files *.php>
Also, just to explain further, in case it's important. This is a typical situation:
Page checks if user has certain cookies.
If he does, it shows the 'You're already logged in" msg.
If he doesn't, it shows the login form.
I appear to be having issues with both cookies being set, and, when they are set/unset - the correct msg being shown.
The different msg's are all variables passed to a template system.
The only way I've found round this (and its not really appropriate on all pages) is to have the page refresh itself using the PHP header() command. This seems to force the browser to reload.
It's a 'kludgy' solution at best though....
Thanks
Nick
If the [AOL] servers have a current copy of a requested web object, it will be served
...which is precisely why we need to control the cacheability [mnot.net] of our pages, images, scripts, etc. by specifying when these objects cease to be "current."
Using the snippet of .htaccess code I provided above, plus more, I control the expiry time of all objects on my sites, and after thorough testing [ircache.net], I have no trouble with AOL or any other caching proxies of any importance. There may be a few services out there which disregard or mishandle HTTP headers related to cache control, but AOL is not one of them.
Nick,
Yes, as DrDoc answered, "*.php" should work fine. See the Apache core documentation on <Files> for details.
HTH,
Jim
Opera.
No matter what I do, I just can't get it to either NOT cache a page or to (on occasion) to even refresh a page to a new location.
All I'm doing on the page (chronalogically) is this:
Here's what happens.
When Opera loads the page that unsets the cookies and refreshes to the 'login' page the refresh 9/10 works but, you have to hit reload for the cookies to unset. - If you do hit reload, it will unset the cookies and refresh to the 'login' page.
On the login page, it still says 'welcome Nick W' - NOT 'welcome Guest' as it should. (same no cache headers are sent with this page). As there is no 'uname' cookie it and all the no cache headers are sent with this page it should not know what Nick W is right?
Now, Brett doesn't seem to have any trouble here on WebmasterWorld, I logged in and out a few times with no problem whatsoever.
So, i'm lost. I've examined everything and cannot pinpoint the area that's causing the trouble.
I've even put the no-cache stuff in the <head> of the html and copy'n'pasted the the exacts <meta> tags that Opera recoomend on their site.
It works exactly as intended in Moz, I've not tried Win IE as it's only a development site on my home machine and not on the www at the moment...
Nick
Hmm.. tricky. Do you make sure to assign a value to the cookie when it's deleted? I've had problems with Opera in the past if I pass an "empty" cookie to it ..
No clue about the refresh thing. Are you using JavaScript cookies, or PHP/Perl?
[pre]
<?
$time=60*60*24*$DEFAULT_COOKIE_TIME;
setcookie("id", "", time()-$time, "/", ".site.org");
setcookie("uname", "", time()-$time, "/", ".site.org");
setcookie("logged_in", "", time()-$time, "/", ".site.org");
header("Refresh: 3;URL=index.php");
?>
<html>
<head>
<title>Your Browser will Not Refresh</title>
</head>
<body>
<h1>Your Browser will Now Refresh</h1>
<p>Please <a href="/memberadmin/">click here.</a> if it
doesn't.</p>
</body>
</html>[/pre]
The Refresh header is just cos I wanted to see if it made a difference with a delay. (works same with 'Location: ').
The capitialized variables are the defauts the cookies are set with. eg $DEFAULT_COOKIE_TIME=150 (6mts).
Guess the values are not being set?
Nick