With HTML5, creating a cache manifest file makes it easy to create an offline version of your Web app.
Application caching brings three benefits to your app:
- Offline Browsing-users can use them when the app is offline
- Speed-cached resources are loaded faster
- Reduce server load-The browser will download only updated or changed resources from the server.
Cache Manifest Basics
To enable application caching, include the manifest attribute in the
1 <! DOCTYPE HTML > 2 < manifest= "Demo.appcache">3 ... 4 </ HTML >
Pages that specify manifest are cached when the user accesses them. If the manifest attribute is not specified, the page is not cached
Manifest file
- 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 are not cached
- FALLBACK -Files listed under this heading provide a fallback page when the page is inaccessible (e.g. 404 pages)
CACHE MANIFEST
The first line, CACHE MANIFEST, is required
CACHE Manifest/theme.css/logo.gif/main.js
When the manifest file is loaded, the browser downloads the three files from the root directory of the Web site. These resources are then available, regardless of when the user disconnects from the Internet.
NETWORK
"Login.php" is never cached and is not available offline
FALLBACK
1 FALLBACK: 2 /html//offline.html
The first URI is a resource, and the second is a substitute.
Offline: "offline.html" instead of/html5/
Complete Manifest file
1 CACHE MANIFEST 2 # 2012-02-21 v1.0.0 3 /theme.css 4 /logo.gif 5 /main.js 6 7 NETWORK: 8 login.php 9 Ten FALLBACK: /html//offline.html
HTML5 Application Cache