25.02.2013 Views

Peter Lubbers - Pro HTML 5 Programming

Pro HTML 5 Programming

Pro HTML 5 Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Table 10-2. The Six Cache States<br />

Numerical<br />

<strong>Pro</strong>perty<br />

Cache Status<br />

0 UNCACHED<br />

1 IDLE<br />

2 CHECKING<br />

3 DOWNLOADING<br />

4 UPDATEREADY<br />

5 OBSOLETE<br />

CHAPTER 10 ■ CREATING <strong>HTML</strong>5 OFFLINE WEB APPLICATIONS<br />

Most pages on the Web today do not specify cache manifests and are uncached. Idle is the typical<br />

state for an application with a cache manifest. An application in the idle state has all its resources stored<br />

by the browser with no updates in progress. A cache enters the obsolete state if there was at one point a<br />

valid cache but the manifest is now missing. There are events (and callback attributes) in the API that<br />

correspond to some of these states. For instance, when the cache enters the idle state after an update,<br />

the cached event fires. At that time, an application might notify the user that they can disconnect from<br />

the network and still expect the application to be available in offline mode. Table 10-3 shows some<br />

common events and their associated caches states.<br />

Table 10-3. Common Events and Their Cache States<br />

Event Associated Cache State<br />

onchecking CHECKING<br />

ondownloading DOWNLOADING<br />

onupdateready UPDATEREADY<br />

onobsolete OBSOLETE<br />

oncached IDLE<br />

Additionally, there are events indicating update progress, when no update is available, or when an<br />

error has occurred:<br />

• onerror<br />

• onnoupdate<br />

• onprogress<br />

249

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!