Greetings, I was wondering if anybody knows of a way to programmatically stop client's browsers from caching certain website pages? I have a news section on my website that seems to cache really bad. Anybody have any suggestions? Sincerely, Travis Walters
If you are dealing with similar things I stick this bit of code in any page you don't want caching session_cache_expire( 0 ); session_cache_limiter( "nocache" ); 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"); PHP: It basically says - Do not cache this page, No really don't, Im not kidding don't cache it and so and so forth. Any other languages im not too sure. Thanks
Hey there, For coldfusion, I found something that says.. <cfcache action="flush"> For some reason, it does not appear to be working too well though. I thought there would be some sort of javaScript solution since the cache is happening client side. Thanks for the PHP solution though. It will come in handy if I ever make a PHP site. I really love coldfusion though Sincerely, Travis Walters
The CF example looks like it is clearing the server cache rather than the client - you would need to see what renders as the way to do it is with header/ meta tags. Response.AddHeader("cache-control", "no-store, must-revalidate, private") Response.AddHeader("Pragma", "no-cache") Code (markup): is the ASP/ ASP.Net version but the other option is to add a historic absolute expiry date
Maybe this works: <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> or <META HTTP-EQUIV="EXPIRES" CONTENT="Mon, 22 Jul 2002 11:12:01 GMT">