Ali
Ali

Reputation: 27

IE reverts back to before changes

I am having a problem with a page on my site, basically you choose a a few options and then submit the changes to the database and the page refreshes and displays the updated changes, but then if I click on the URL tab at the top of IE8 and press ENTER on the keyboard the page reverts back to before the changes where made???? its really confusing me, but then if I refresh the page again with the refresh button then the changes I made come back again.

Any help with why this is happening would be great?

I am using PHP and Javascript on my webpage.

Regards Alistair

Upvotes: 0

Views: 88

Answers (1)

m.edmondson
m.edmondson

Reputation: 30872

Does the URL have variables within it? If not IE is using caching.

When you visit a site in any modern browser it will store it's own local copy of that page. When you then go to the URL tab at the top and press enter again the browser realises it has it's own local copy, and chooses to show you this instead.

This improves the responsiveness of every page you visit on the internet, however when you refresh the page it checks the HTTP header from the server and if it has changed (it has) it will show the new version of the page.

You need to prevent caching, to do that in PHP just add the following:

// Disable caching of the current document:
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');// Date in the past
header('Pragma: no-cache');

or you could even use META tags.

Please note that regardless of what you do, these are simply requests that the browser can ignore at will. You have no control of the client's browser, although most will comply.

Upvotes: 2

Related Questions