HTML and CSS Reference
In-Depth Information
example file, if login.html isn't available in the cache, render fallback-login.html . You can use
shortcuts in the FALLBACK section to provide more general redirects, such as the following:
/resources /resource.jpg
This tells the browser that if the browser is offline and can't access anything in the
resources folder, it should replace any references to items in the resources folder with
resource.jpg . Note that resource.jpg is cached because it's specified in the FALLBACK section.
You don't need to also specify resource.jpg in the CACHE section.
Using the AppCache API
As with Web Storage, the application cache is available in JavaScript as a global object. The
following code gets a reference to the AppCache global object:
var appCache = window.applicationCache;
When you're using the application cache to make pages available offline, one of the more
useful things you can do when the page is loaded is verify its status. You achieve this by
evaluating the status property of the AppCache object. The status property could be one of
the values listed in Table 1-14.
TABLE 1-14 The application cache status property
Status
Description
The web application isn't associated with an application manifest.
Uncached
The caching activity is idle, and the most up-to-date copy of the cache is being used.
Idle
The application manifest is being checked for updates.
Checking
The resources in the application manifest are being downloaded.
Downloading
The resources listed in the manifest have been successfully downloaded.
UpdateReady
The manifest can no longer be downloaded, so the application cache is being
deleted.
Obsolete
After you know the cache status, two methods on the AppCache object can be useful.
Table 1-15 lists these.
TABLE 1-15 Methods available with the applicationCache object
Method
Description
Indicates that the cache be replaced with a newer version.
swapCache
Tells the browser to update the cache if an update is available.
update
 
Search WWH ::




Custom Search