Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

browser cache question 1

Status
Not open for further replies.

Dweezel

Technical User
Feb 12, 2004
428
GB
I'm using the following on a page to prevent browser cacheing. The page is constantly updated and this is meant to force a refresh:

Code:
<?php
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-store, no-cache, must-revalidate");  
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");                        
?>

Is it only the dynamic, php generated parts of the page that should be prevented from cacheing by using the above code, or is it the entire contents of the page including the images?
Everything still seems to be cacheing in my browser (IE6).

Thanks.
 
Assuming the no-cache code is right (I personally can't remember off-hand), then it's the entire page that it applies to, as the browser doesn't know what was generated by php.
 
Thanks KempCGDR.

I don't think the code can be wrong as it's taken straight from the PHP manual and I've checked it carefully. Yet everything from the page is still cacheing to temporary internet files, and the page is definitely not refreshing when I go back to it, either by re-clicking a link, or using the back button.

Any help on this appreciated.
 
Hmmm.... I can imagine the back button not bothering to fetch it again if you're using IE as I've noticed that happen quite often, but going to the page via links or refreshing it definately should grab a new copy of it. Once again assuming you're using IE, if you go to Tools -> Internet Options and then click the 'Settings...' button on the second group down (Temporary Internet Files), what is that set to? I believe 'Never' forces it not to grab new copies.
 
Thanks for tip, but unfortunately mine is set to 'automatic' which I think is the default, so it can't be that.

Thanks though KempCGDR.
 
As far as I can tell, my browser is caching the images + j and css files but not the actual page.
 
Yep. Just went back to my temp internet files and looked a little closer. Like you say everything is cacheing except the html. That's exactly what I want to happen, so I didn't have a problem after all [blush].

Sorry about that KempCGDR, but thanks a lot for helping.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top