cache control not working - clashing of headers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
victor
Forum Commoner
Posts: 65
Joined: Fri Feb 13, 2004 1:36 am

cache control not working - clashing of headers

Post by victor »

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()?

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 trick
Don't really get what he was trying to say:

Code: 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";
any clue to the above approach ? where is local.inc and where can i locate and modify the Session class?
Post Reply