Browser cache: if we change something, force the user to get a new version, not a local cached version

We often make changes to our site (which uses caching), and sometimes the user does not know to refresh the page to get the latest copy of it.

If we refresh the page, how can we make the users browser know that there is a new version of the server and use this cached page instead of their browser?

+4
source share
2 answers

Or you can configure the http header to force a reboot every n-th second. This is an easy way, but you probably don't want it. The second way is to use javascript requesting the server via ajax if there is an update. If so, force a reboot.

About the cache, you can set the expire header on the page.

+5
source

I know that the question was answered, but another way is to set quests at the end of your URL to use the version number:

www.asite.com?version=1.0 //force update www.asite.com?version=1.1 www.asite.com?version=1.2 

The browser should request a new cache each time the version number changes.

+1
source

All Articles