How to use Application Cache

The Application Cache is controlled by a manifest file. A manifest file is a simple text file with a MIME-type of text/cache-manifest. This file lists all the resources that should be added to the Application Cache. If the manifest file is added to a HTML page, that page is also added to the Application Cache. Both the HTML page containing a manifest file and the resources listed in the manifest file are therefore added to the Application Cache. A manifest file can be added to a HTML document as an attribute of the HTML element as follows:

A typical manifest file looks like:
This example demonstrates the syntax of the manifest file:

  • CACHE MANIFEST: - This is the required heading of the manifest file.
  • #Version: 2182 - This line is a comment as indicated by the # symbol at the start of the line. Once a resource is cached, the browser will continue to show the cached version, even if you change the resource on the server. Any change in the manifest file, including in a commented line, will cause the entire cache to be updated. In this manifest file example this comment is therefore used to control when the browser updates the Application Cache. It is recommended practice therefore to add a version comment to the manifest file that can be updated every time any resource in the manifest file is required to be updated.
  • CACHE: - This line indicates the start of a CACHE section. A CACHE section contains a list of resources that should be added to the Application Cache. As with all sections, the resources can be listed with either a absolute http://mobile.cdn.net/resources/core/all_2182_.css or a relative /resources/core/all_2182_.css path. If no section heading is provided this is the default section.
  • FALLBACK: - This line indicates the start of a FALLBACK section. A FALLBACK section contains a list of resources or pages that should be falled back to if a resource is unavailable, this fallback happens typically when there is no internet connection. In the example above if any page is not available for the path /online-chat/ then the /offline.html page will be displayed. This prefix rule of matching only the prefix of a URL is supported for both the FALLBACK and NETWORK sections.
  • NETWORK: - This line indicates the start of a NETWORK section. A NETWORK contains a list of resources that can be loaded from the network (if available). In this case a * indicates an "open" manifest file which allows any resources not listed to be downloaded as required. If the manifest file was "closed" and did not have a * then any resources not listed in either the NETWORK section or the CACHE section would not be downloaded. Therefore, a "closed" manifest file can be used to control what resources are downloaded for a specific page. However, more often a "closed" manifest file is an additional source of bugs because any new resource added must also be listed in the manifest file for it to be downloaded. I recommend using an "open" manifest file by adding the * in a NETWORK section.
Google