Users of typical online Web applications are only able to use the applications while they have a connection to the Internet. When they go offline, they can no longer check their e-mail, browse their calendar appointments, or prepare presentations with their online tools. Meanwhile, native applications provide those features: e-mail clients cache folders locally, calendars store their events locally, presentation packages store their data files locally.
In addition, while offline, users are dependent on their HTTP cache to obtain the application at all, since they cannot contact the server to get the latest copy.
The HTML5 specification provides two solutions to this: a SQL-based database API for storing data locally, and an offline application HTTP cache for ensuring applications are available even when the user is not connected to their network.
The mechanism for ensuring Web applications are available even
when the user is not connected to their network is the
manifest attribute on the
The attribute takes a URI to a manifest, which specifies which files are to be cached. A typical file looks like this:
CACHE MANIFEST index.html help.html style/default.css images/logo.png images/backgound.png NETWORK: server.cgi
This file specifies several files to cache, and then specifies
server.cgi should never be cached, so
that any attempt to access that file will bypass the cache.
The manifest can then be linked to by declaring it in the (HTML) application, like this:
<!DOCTYPE HTML> <html manifest="cache-manifest"> ...
server.cgi file would be white-listed
(put in the
NETWORK: section) so that it can
be contacted to get updates from the server, as in:
event-source element is a new feature in HTML5
that allows servers to continuously stream updates to a Web page.)
The application cache mechanism also supports a way to opportunistically cache (from the server) a group of files matching a common prefix, with the ability to have a fallback page for rendering those pages when offline. It also provides a way for scripts to add and remove entries from the cache dynamically, and a way for applications to atomically update their cache to new files, optionally presenting custom UI during the update.