HTML5 introduces new methods for a web site or web application to function without a network connection as, having some level of access is better than nothing.
The application cache is controlled by a plain text file called a manifest, which contains a list of resources to be stored for use when there is no network connectivity. The list can also define the conditions for caching, such as which pages should never be cached and even what to show the user when he follows a link to an uncached page. If the user goes offline but has visited the site while online, the cached resources will be loaded so the user can still view the site in a limited form. An example manifest file is given
There are three different sections in a manifest file
|CACHE||A list of explicit URLs to request and store|
|FALLBACK||What to do when an offline user attempts to access an uncached file|
|NETWORK||Which resources are available only while online|
Referencing the manifest – Referencing a manifest file is done by adding the manifest attribute to <html> tag a
<html lang=”en” manifest=”/offline.appcache”>
// your html document
Cache refresh – Once a cache has been successfully downloaded, the browser will retain those assets until either the user clears the cache or an update trigger at web server. Triggering an update with manifest file requires that the contents of that file change, not just the assets themselves. Updating the assets on your server will not trigger a cache update. Adding or removing resources completely also requires to edit manifest file. But to just amending an already cached stylesheet, comments are used by adding a version number comment which can be changed when to trigger an update, as
# Version 9
The next time to trigger a cache refresh can be done by incrementing the version number. When the user next visits the online version of a page including this manifest, it will re-download the manifest file, notice the change, download the listed assets, and purge the existing cache.