2
votes

I'm working on a web application, and as a beginner web developer, I have trouble working out the cache manifest. The goal is for the webpage to load its cached file if the user is offline, and if the user is online, the webpage will refresh itself and cache the updated file. So far, my cache.manifest file looks like this:

CACHE MANIFEST
index.htm

This caches the page to be accessible offline just fine, but if the user refreshes the URL online, it'll still display the old cached file, even if I updated the page. How can I solve this?

1

1 Answers

1
votes

By design and by definition, the HTML5 cache manifest works so that the cached data is used unless the content of the cache manifest has changed. This makes little sense for web pages, but it can make a lot of sense for applications distributed on the Web.

If you really have an application, you normally have several files listed in the manifest (and the HTML file itself need not be listed – it is implied). Then you should edit the manifest whenever the application has been modified and it needs to be reloaded. You need to change the actual content in the manifest, even if the list of files has not changed. A common technique is to have a comment line (starting with #) containing, say, a version number or a date stamp indicating the latest change.