UPDATE THE APPLICATION CACHE

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);
 }

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.