By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,746 Members | 1,924 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,746 IT Pros & Developers. It's quick & easy.

Why PHP cache control doesn't work?

P: 16
Hi, guys

Is there anything wrong with this code?

Expand|Select|Wrap|Line Numbers
  1. header("Cache-Control: no-cache, must-revalidate"); 
  2. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); 
i put them in most top, before html tag, even before session_start.
But in some browser, they just don't work.

If i hit BACK button the value submitted from the source form are still there.
In my head, if i hit the BACK button, the form should be clear again.

What's the problem? I don't understand.

Thanks in advance...
Oct 21 '08 #1
Share this Question
Share on Google+
3 Replies


Atli
Expert 5K+
P: 5,058
Hi.

Not all browsers will use or even understand the Cache-Control or Expires headers. They are just suggestions, telling the browser how you would like the cache to be handled. How each browser actually handles the cache is up to the browser.

It is always best to assume that the browser will not understand such features, but consider it a plus when they do.
If your application relies on such a feature, you should find a server-side alternative.

You can never trust that a browser will do what it is told.
Oct 21 '08 #2

P: 16
Thanks Atli,

In this case, how do I make sure that particular page is non-cacheable using PHP?
Is it by diligently clear every form each time they loaded?

Thanks in advance
Oct 21 '08 #3

pbmods
Expert 5K+
P: 5,821
Heya, agun.

You might find this article to be of some interest (http://www.mnot.net/cache_docs/).
Oct 22 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.