DOMApplicationCache Class Reference
Availability | Available in Safari 4.0 and later. Available in iPhone OS 2.2 and later. |
Companion guide | |
Overview
A DOMApplicationCache
object is used to store resources—such as, HTML, JavaScript, CSS, and images—locally. This allows your web application to continue running offline when there is no network connection. The cache persists after Safari exits, so it can be used by multiple browser sessions. There is one application cache per browsing context.
Tasks
Accessing Properties
Handling Events
Updating the Cache
Properties
oncached
Sent when the update process finishes for the first time—that is, the first time an application cache is saved.
attribute EventListener oncached;
Availability
- Available in Safari 4.0 and later.
- Available in iPhone OS 2.2 and later.
onchecking
Sent when the cache update process begins.
attribute EventListener onchecking;
Availability
- Available in Safari 4.0 and later.
- Available in iPhone OS 2.2 and later.
ondownloading
Sent when the update process begins downloading resources in the manifest file.
attribute EventListener ondownloading;
Availability
- Available in Safari 4.0 and later.
- Available in iPhone OS 2.2 and later.
onerror
Sent when an error occurs.
attribute EventListener onerror;
Availability
- Available in Safari 4.0 and later.
- Available in iPhone OS 2.2 and later.
onnoupdate
Sent when the update process finishes but the manifest file does not change.
attribute EventListener onnoupdate;
Availability
- Available in Safari 4.0 and later.
- Available in iPhone OS 2.2 and later.
onprogress
Sent when each resource in the manifest file begins to download.
attribute EventListener onprogress;
Availability
- Available in Safari 4.0 and later.
- Available in iPhone OS 2.2 and later.
onupdateready
Sent when there is an existing application cache, the update process finishes, and there is a new application cache ready for use.
attribute EventListener onupdateready;
Availability
- Available in Safari 4.0 and later.
- Available in iPhone OS 2.2 and later.
status
The current status of the application cache. One of the values described in "Constants.”
readonly attribute unsigned short status;
Availability
- Available in Safari 4.0 and later.
- Available in iPhone OS 2.2 and later.
Methods
add
Forthcoming
void add(in DOMString uri) raises(DOMException);
Availability
- Available in Safari 4.0 through Safari 4.0.2.
swapCache
Replaces the active cache with the latest version.
void swapCache() raises(DOMException);
Availability
- Available in Safari 4.0 and later.
- Available in iPhone OS 2.2 and later.
update
Manually triggers the update process.
void update() raises(DOMException);
Availability
- Available in Safari 4.0 and later.
- Available in iPhone OS 2.2 and later.
Constants
Constants that indicate the status of the application cache.
Constant | Description |
---|
UNCACHED | The object isn’t associated with an application cache. This can occur if the update process fails and there is no previous cache to revert to, or if there is no manifest file. const unsigned short UNCACHED = 0;
|
Available in Safari 4.0 and later. Available in iPhone OS 2.2 and later. |
IDLE | The cache is idle. const unsigned short IDLE = 1;
|
Available in Safari 4.0 and later. Available in iPhone OS 2.2 and later. |
CHECKING | The update has started but the resources are not downloaded yet—for example, this can happen when the manifest file is fetched. const unsigned short CHECKING = 2;
|
Available in Safari 4.0 and later. Available in iPhone OS 2.2 and later. |
DOWNLOADING | The resources are being downloaded into the cache. const unsigned short DOWNLOADING = 3;
|
Available in Safari 4.0 and later. Available in iPhone OS 2.2 and later. |
UPDATEREADY | Resources have finished downloading and the new cache is ready to be used. const unsigned short UPDATEREADY = 4;
|
Available in Safari 4.0 and later. Available in iPhone OS 2.2 and later. |