HTML and CSS Reference
In-Depth Information
6. Browser: processes the manifest and requests all the
itemsĀ in the manifest
7. Server: returns the requested manifest assets
8. Browser: application cache has updated, trigger an event
stating so
However, it's important to know that even though the assets
may have changed, any previously loaded assets will not have
changed (for example, images don't suddenly change, and old
JavaScript functions haven't changed). In fact, at this point in the
application's life, none of the new cache is available. Only when
the page is reloaded will the new cached assets come into play
and become available.
We'll look at how we can get our hands on these new assets by
looking at the applicationCache object.
applicationCache
The applicationCache is the object that notifi es you of changes
to the local cache, but also allows you to manually trigger an
update to the cache. Only if the manifest has changed will the
applicationCache receive an event saying it has updated.
In the process list from the previous section, once the browser
has fi nished loading the cache with the fi les from the manifest,
the update event fi res on the applicationCache . You could use
this event to tell users that the application they're using has
been upgraded and they should reload the browser window to
get the latest and greatest version of your app. You can do this
using a simple event listener and a notifi cation:
applicationCache.onUpdateReady = function () {
// the cache manifest has changed, let's tell the user to
// reload to get whizz bang version 2.0
notifyUserOfUpgrade();
};
However, what if you wanted to tell the user what had changed?
Or even perhaps try to dynamically reload some portion of
functionality. Strictly speaking, it's possible, but it might be
tricky depending on your application. Nonetheless, to load
the newly downloaded cache into memory, you can use the
applicationCache.swapCache() method:
 
 
Search WWH ::




Custom Search