Cache Manifest Basics
Cache Manifest Basics
To enable application caching, include the manifest attribute in the tag of the document:
...
Each page that specifies a manifest will be displayed on the user's page It will be cached when accessed. If the manifest attribute is not specified, the page will not be cached (unless it is specified directly in the manifest file).
The recommended file extension for manifest files is: ".appcache".
Please note that the manifest file needs to be configured with the correct MIME-type, that is, "text/cache-manifest". Must be configured on the web server.
Manifest File
Manifest files are simple text files that tell the browser what is cached (and what is not cached).
Manifest files can be divided into three sections:
CACHE MANIFEST - Files listed under this heading will be cached after the first download
NETWORK - Files listed under this heading require a connection to the server and will not be cached
##FALLBACK - The files listed under this heading specify the fallback page when the page is inaccessible (such as a 404 page)
The first line, CACHE MANIFEST, is required:
CACHE MANIFEST/theme.css/logo.gif
/main .js
The above manifest file lists three resources: a CSS file, a GIF image, and a JavaScript file. When the manifest file loads, the browser downloads these three files from the root directory of the website. Then, whenever the user disconnects from the Internet, these resources are still available.
The following NETWORK section specifies that the file "login.php" is never cached and is not available offline:
NETWORK:
login.php
An asterisk can be used to indicate that all other resources/files require an Internet connection:
*
The following FALLBACK subsection specifies that if an Internet connection cannot be established, all files in the /html5/ directory are replaced with "offline.html":
FALLBACK:
/html/ /offline.html
Note: The first URI is the resource, the second one is the substitute.
Once an app is cached, it remains cached until the following occurs:
The user clears the browser cache
Manifest file modified (see tips below)
Updated application cache by program