Using application cache to work offline
When, for some reason, our users don't have web access or the website is down for maintenance (or even broken), our web-based applications should also work offline. The browser cache is not robust enough to be able to do this, so HTML5 has given us the mechanism of ApplicationCache
. This cache tells the browser which files should be made available offline. The effect is that the application loads and works correctly, even when the user is offline. The files to be held in the cache are specified in a manifest file, which has a .mf
or .appcache
extension.
How to do it...
Look at the appcache
application; it has a manifest file called appcache.mf
.
The manifest file can be specified in every web page that has to be cached. This is done with the manifest attribute of the
<html>
tag:<html manifest="appcache.mf">
If a page has to be cached and doesn't have the manifest attribute, it must be specified in the
CACHE
section of the manifest file. The...