HTML and CSS Reference
In-Depth Information
Try it out
That's it! The sample application should now be fully functional. Try it out on a device or
browser that supports IndexedDB or Web SQL. (iOS, Android, BlackBerry Torch, Opera
Mobile, Chrome, Firefox, Safari, and Opera all work.) If both IndexedDB and Web SQL
are available in the browser, the application will favor the former. In the next and final sec-
tion of this chapter, you'll learn how to ensure an application will work offline using an
application cache manifest file. You should then have an application that stores all of its
data on the client and is usable both online and offline.
5.4. Creating a web application that works offline: using the applicat- tion
cache manifest
Until recently, web applications have been used primarily in connected environments, on
desktop or laptop computers, where the majority of the time an internet connection is avail-
able. But as rich web applications become more prominent as realistic alternatives to their
desktop counterparts, and as mobile applications continue to gather momentum, the need
grows for web applications to work in scenarios where connectivity is not available.
Application cache
To address these demands, HTML5 provides a file called the application cache manifest.
This file, in its most basic form, specifies a list of web resources needed by a web applic-
ation. Browsers that support the manifest feature will use the list to provide a web applic-
ation with access to a local cache of these web resources. As a result, the web application
can run offline.
For resources only available from the network, the cache manifest can specify fallback
client-side URIs for offline activity. For instance, if an application relies on a JavaScript
file to save data to a server, then the cache manifest would specify a client-side URI point-
ing to a JavaScript file that uses local requests for client-side storage.
Search WWH ::

Custom Search