November 2011
Intermediate to advanced
384 pages
13h 23m
English
You may notice a very strange bug in the pages you store under the application cache. None of them are updating, despite the web server providing an updated file and manifest. At the risk of sounding clichéd, this is not a bug; it is a feature!
The AppCache is designed to supersede all network activity for resources. Effectively, after a file is AppCached, it will always be served from the browser’s local copy. So how do you force the application cache to update?
When your page loads, listen for the AppCache updateready event, and when it fires, swap the new cache in:
if ('applicationCache' in window) {
applicationCache.
addEventListener('updateready', function() {
applicationCache.swapCache(); }, false);
}
Read now
Unlock full access