Mobile app version of vmapp.org
Login or Join
Sims2060225

: Clear the cache of the last visited page I have an HTML page that has shows if a server is online of offline via an IFRAME transcluding a php file. If someone clicks on a link, like to

@Sims2060225

Posted in: #Browsers #Cache #CacheControl

I have an HTML page that has shows if a server is online of offline via an IFRAME transcluding a php file.

If someone clicks on a link, like to turn the server on or off and presses the Back button on the browser, the browser loads a cached version of the page and still displays the server as "off" unless the page is refreshed. I know there are other ways to go about this but I would like for just that page to not be cached so that when a user reaches that page via the Back button, it will have to redownload the page.

How can this be done? Is it even possible?

Putting header("Cache-Control: no-cache, must-revalidate"); in the php file did not work.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sims2060225

1 Comments

Sorted by latest first Latest Oldest Best

 

@Gloria169

Of course it is possible. Try sending these headers in your PHP code:

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Expires: Tue, 1 Jan 1980 00:00:00 GMT


The Expires header can have any valid date in the past (preferably quite few years back, in case system time on that PC is set in the past as well).

These headers work fine for me in all browsers (I remember testing them 3 or 4 years ago in IE 6, Firefox 2, Opera 9, Safari 4).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme