HTML5 Offline: browser loads cached index page even when online
When a page is requested, it is cac开发者_运维百科hed as per the manifest file. However, when the page is updated, and the device is online, the file is not updated even though the computer is offline (it's online).
How can we work around this? Is there any way to tell the client to load the page from the server and not the cache when it's online?
An offline app that has been cached will always load from the cache before attempting to go online.
Having said that, you can create a dynamic cache manifest that will update itself if any file has changed, even if no files have been added/removed. Essentially you create a hash of each file, and if the hash changes the manifest is updated. I explain how to do this in more detail here (concept originally published here).
Look here: http://www.w3.org/TR/html5/offline.html#appcacheevents
Apparently, when a page declares a manifest, the browser should look at the manifest file to see if anything has changed, and then refresh all the resources it mentions if it has. If the manifest file has not changed, then nothing else is refreshed.
I guess you would change a comment in the manifest file, so that it will be seen to have changed, when the actual list of resource names has not changed -- perhaps, a version number or date comment.
精彩评论