Why PHP cache control doesn't work?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agun
    New Member
    • Oct 2008
    • 16

    Why PHP cache control doesn't work?

    Hi, guys

    Is there anything wrong with this code?

    Code:
    header("Cache-Control: no-cache, must-revalidate"); 
    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...
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    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.

    Comment

    • agun
      New Member
      • Oct 2008
      • 16

      #3
      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

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, agun.

        You might find this article to be of some interest (http://www.mnot.net/cache_docs/).

        Comment

        Working...