O'Reilly logo

HTML5: Your visual blueprint™ for designing rich web pages and applications by Adam McDaniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required