HTML and CSS Reference
In-Depth Information
FIGURE 1-52 Web storage contents
The availability of local web storage can improve both end-user experience and
performance of your web applications by saving round trips to the server to retrieve or store
temporary data. You must consider the local web storage as temporary . Even when you're
using localStorage as opposed to sessionStorage , you should think of the storage as temporary
and design your applications so that they can fall back on default values and behavior if the
user purges the web storage. Web storage provides a way to make data available locally and
even persist across browser sessions. These techniques work with a live connected website.
If you want to make an application available offline, in a disconnected way, you can use the
AppCache API, which is covered next.
Using the AppCache API
The ability to continue to work with web applications when disconnected from an Internet
source has become particularly important in today's mobile world. This section talks about
how to create an application that works when disconnected by using the Application Cache
API, also commonly called the AppCache API.
The AppCache API makes content and webpages available even when a web application
is in offline mode. AppCache stores files in the application cache in the browser. Just as with
Web Storage, the amount of data the browser can store locally is limited for offline use. Two
components make up the AppCache API: the manifest file and a JavaScript API to support it.
Using AppCache manifest
Specifying that a page should be available for offline use is as easy as adding an attribute to
the HTML element in the page. Here's an example:
<html manifest="webApp.appcache">
The manifest attribute on the html element tells the browser that this webpage needs to
be available offline. The value of the manifest attribute points to a manifest file. The name of
the file is a convention more than a requirement; you can name the file anything, but the file
extension is usually .appcache .
Search WWH ::

Custom Search