Question

I have a cache manifest with a comment in it

# Version 3.2

in order to update all the App I simply change the Version number. It works, but:

When I update the manifest, everything is updated correctly (new cache is filled) but the actual files are taken ONE more time from the (old) cache. when I reload twice everything is updated. Is this behaviour correct? Using chrome 21.

Thanks

Was it helpful?

Solution

Yes, this is the current "correct" behaviour. This is what happens:

When you just made changes to the manifest file, and you refresh the browser, this is what happens (assuming you're online)

  • the browser first loads back all the files in the cache
  • then the browser check online for your manifest file
  • it detects that the manifest file has changed, it will then proceed to download the new files
  • however, keep in mind, at this time, you will still be looking at your 'old files' because the browser has loaded the old files before going online to download the 'new files'
  • if at this point, if you hit refresh again (2nd time), you should get the 'new files'

This is currently the standard behaviour. Some people put some event handlers to prompt the user to do another refresh (after the 1st refresh)

Personally, I think the browser should be responsible to alert the user to make another refresh after finish downloading the new files, but right now, most people put in event handlers from the "window.applicationCache" to fire events to help manage this.

To look at an example of using window.applicationCache, go here : http://www.html5rocks.com/en/tutorials/appcache/beginner/

it's under the "Updating the Cache" section.

OTHER TIPS

It is possible to instantly swap the cache as described here:

function updateSite(event) {
    window.applicationCache.swapCache();
}
window.applicationCache.addEventListener('updateready', updateSite, false);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top