Page 1 of 1

preventing caching

Posted: Wed Jun 26, 2002 2:15 am
by 9902468
I encountered strange bug that sonmehow prevented me from seeing the changes that I made in my code. After noticing that hitting reload few times solved this problem (Or the *¤##&¤"! words that I shouted...,) I realized that this is most likely browser (or proxy) caching that kindly speeds up my load times...
Anyhow, I can prevent caching with header(), right?, but all solutions I've seen are more or less a bit shaky, and have statement like "This works on netscape x.xx, your mileage may vary." Now, if you could kindly write down what worked for you, or even better, if you know the universal solution to this you are allowed to write it down ;)

thx

-9902468

Posted: Wed Jun 26, 2002 9:20 am
by volka
from header-function manual
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"); // HTTP/1.0
looks like a complete round-strike against any chaching ;)