cache control not working - clashing of headers
Posted: Wed Dec 15, 2004 9:25 am
read this article
http://www.phpbuilder.com/tips/item.php?id=123
Seems like default headers are sent by phplib session code that confuses IE and results IE to pull from the cache, could this be the problem as I'm using session_start()?
Don't really get what he was trying to say:
any clue to the above approach ? where is local.inc and where can i locate and modify the Session class?
http://www.phpbuilder.com/tips/item.php?id=123
Seems like default headers are sent by phplib session code that confuses IE and results IE to pull from the cache, could this be the problem as I'm using session_start()?
Code: Select all
BUT, and here's the kicker -- if you're using PHPLib session code, it will also attempt to send out some of these headers. The way in which the headers are sent is not determined by PHP -- it's determined by Apache. If your headers conflict with the PHPLib headers IE will get a confused set of headers and will pull the doc from cache. This was basically the root of my agony -- I was trying to set the headers in my code explicity, but PHPlib was sending a slightly different version of the headers. I didn't check to see what IE was finally getting, but whatever it was didn't do the trickCode: Select all
So, if you are using PHPlib, I suggest the following:
In your local.inc file where you subclass Session, overload the put_headers() method. Copy the put_headers method directly from the Session class, but add the following:
case "iehack":
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache");
header("Cache-Control: post-check=0,pre-check=0");
header("Cache-Control: max-age=0");
header("Pragma: no-cache");
break;
just before the default: tag.
Now add the line:
var $allowcache = "iehack";