Reputation: 13604
I developed a web app that involves an ever-changing resource (the app updates a database, which in turns means the page changes). In Chrome, when I go to another site by following a link and return by a back button, it shows the original version of the page rather than the latest version. If I refresh the page, I'll see the changes. Do you know how to deal with this problem? Is there any way to force the Chrome to refresh the page or keep the latest version?
Upvotes: 1
Views: 386
Reputation: 12973
The obvious answer is to set the Expires header to the current or a previous time (in the right RFC format) to specify the page expires immediately. However a previous question is also relevant. It appears Chrome caches content for 300 seconds regardless of the Expires/caching headers. Internet Explorer can also cache aggressively.
I doubt there is a good workaround. One possibility might be to set a cookie with the current time when the page is served, and to test it with Javascript in the head of the page. If the value is too old (your choice on how long "too old" is) then force the page to be reloaded using window.location
, perhaps by using a dummy querystring '?d='+Math.random()
to ensure the cached version is not used.
Upvotes: 1