HTML5 Application Cache
In this chapter we learn html5 app cache .
we can make offline version of a web application by creating a cache manifest file
By using application cache we can make accessible without an internet connection.
Application cache gives an application following advantages:
from the server
- It helps speed - it can gain web pages cased resoursce load faster
- reduce server load- It help browser will only download updated resources from server
- Offline browsing - user can browse site in offline no need internet connection
table specify the first browser version that fully supports Application Cache.
HTML Cache Manifest
The example below shows an HTML document with a cache manifest
The content of the document......
Cache Manifest Basics
Cache Manifest are include application cache in in the document's <html> tag:
Every page with the manifest attribute specified will be cached when the user visits it.If the manifest attribute is not specified, the page will not be cached unless the page is specified directly in the manifest file.
The recommended file extension for manifest files is: ".appcache"
Manifest file is a simple text file, which tells the browser what to cache (and what to never cache).
The manifest file has three category :
- CACHE MANIFEST - It is primary maniefest Files listed under this header will be cached after they are downloaded for the first time
- NETWORK -It is Files listed under this header require a connection to the server, and will never be cached
- FALLBACK - It is Files listed under this header specifies fallback pages if a page is inaccessible
The first line, CACHE MANIFEST, is required:
The NETWORK section below specifies that the file "login.asp" should never be cached, and will not be available offline:
An asterisk can be used to indicate that all other resources/files require an internet connection:
The FALLBACK section below specifies that "offline.html" will be served in place of all files in the /html/ catalog, in case an internet connection cannot be established:
Updating the Cache
Once an application is cached, it remains cached until one of the following happens:
- The user clears the browser's cache
- The manifest file is modified (see tip below)
- The application cache is programmatically updated
Example - Complete Cache Manifest File
# 2018-05-21 v1.0.0