HTML5 ApplicationCache

The applicationCache object is your programmatic access to the browser's app cache.

Warning (BlackBerry 6.0 Notice):

Support for Application Cache on BlackBerry Smartphones starts with 6.0.0.418

Supported Platform(s)

- BlackBerry OS 6.0+
- BlackBerry PlayBook
- Ripple Emulator

View Supported Platform Table

APIOS 5.0OS 6.0OS 7.0PlayBookRipple
window.applicationCache   Y Y YY
worker.applicationCache   Y Y YY
swapCache   Y Y YY
update   Y Y YY
status   Y Y YY
UNCACHED   Y Y YY
IDLE   Y Y YY
CHECKING   Y Y YY
DOWNLOADING   Y Y YY
UPDATEREADY   Y Y YY
OBSOLETE   Y Y YY
cached   Y Y YY
checking   Y Y YY
downloading   Y Y YY
error   Y Y YY
noupdate   Y Y YY
obsolete   Y Y YY
progress   Y Y YY
updateready   Y Y YY

Configuration Document Settings

To use all of the API described for this object, you must ensure the following settings are in your configuration document:

This API does not require a <feature> element to be declared in the configuration document of your BlackBerry WebWorks Application.

Permission Elements (PlayBook Only)
This API does not require a <permission> element to be declared in the configuration document of your BlackBerry WebWorks Application.

window.applicationCache


window.applicationCache

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Returns the ApplicationCache object that applies to the active document of that Window.



Code Example(s)

<script type="text/javascript">
  var appCache = window.applicationCache;
</script>

worker.applicationCache


worker.applicationCache

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Returns the ApplicationCache object that applies to the current shared applicationCache.



Code Example(s)

<script type="text/javascript">
  var worker = new Worker('doWork.js');
</script>

doWork.js (the worker):

  var appCache = self.applicationCache()

swapCache


void swapCache()

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Switches to the most recent application cache, if there is a newer one.
This does not cause previously-loaded resources to be reloaded; for example, images do not suddenly get reloaded and style sheets and scripts do not get reparsed or reevaluated. The only change is that subsequent requests for cached resources will obtain the newer copies.



Throws Description
INVALID_STATE_ERR If the current app cache is the most recent

Code Example(s)

var appCache = window.applicationCache;
appCache.update(); // Attempt to update the user's cache.
...
if (appCache.status == window.applicationCache.UPDATEREADY) {
    appCache.swapCache();  // The fetch was successful, swap in the new cache.
}

update


void update()

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Invokes the application cache download process.
Throws an INVALID_STATE_ERR exception if there is no application cache to update.



Code Example(s)

var appCache = window.applicationCache;
appCache.update(); // Attempt to update the user's cache.
...
if (appCache.status == window.applicationCache.UPDATEREADY) {
    appCache.swapCache();  // The fetch was successful, swap in the new cache.
}

cached


void cached()

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Sent when the resources listed in the manifest have been downloaded, and the application is now cached.



Code Example(s)

function handleCacheEvent(e) {
    //...
}
// Fired after the first cache of the manifest.
appCache.addEventListener('cached', handleCacheEvent, false);

checking


void checking()

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Sent when the cache update process begins.



Code Example(s)

function handleCacheEvent(e) {
    //...
}
// Checking for an update. Always the first event fired in the sequence.
appCache.addEventListener('checking', handleCacheEvent, false);

downloading


void downloading()

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Sent when the update process begins downloading resources in the manifest file.



Code Example(s)

function handleCacheEvent(e) {
    //...
}
// An update was found. The browser is fetching resources.
appCache.addEventListener('downloading', handleCacheEvent, false);

error


void error()

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Sent when an error occurs.



Code Example(s)

function handleCacheErro(e) {
    alert('Error: Cache failed to update!');
};
// The manifest returns 404 or 410, the download failed,
// or the manifest changed while the download was in progress.
appCache.addEventListener('error', handleCacheError, false);

noupdate


void noupdate()

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Sent when the update process finishes but the manifest file does not change.



Code Example(s)

function handleCacheEvent(e) {
    //...
}
// Fired after the first download of the manifest.
appCache.addEventListener('noupdate', handleCacheEvent, false);

obsolete


void obsolete()

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Sent when the manifest was found to have become a 404 or 410 page, so the application cache is being deleted.



Code Example(s)

function handleCacheEvent(e) {
    //...
}
// Fired if the manifest file returns a 404 or 410.
// This results in the application cache being deleted
appCache.addEventListener('obsolete', handleCacheEvent, false);

progress


void progress()

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Sent when each resource in the manifest file begins to download.



Code Example(s)

function handleCacheEvent(e) {
    //...
}
// Fired for each resource listed in the manifest as it is being fetched.
appCache.addEventListener('progress', handleCacheEvent, false);

updateready


void updateready()

Supported Platform(s)

 - BlackBerry OS 6.0+
 - BlackBerry PlayBook
 - Ripple Emulator

Description

Sent when there is an existing application cache, the update process finishes, and there is a new application cache ready for use.



Code Example(s)

function handleCacheEvent(e) {
    //...
}
// Fired when the manifest resources have been newly redownloaded.
appCache.addEventListener('updateready', handleCacheEvent, false);

Properties:


Property Type Description Supported Platform(s)
status Number The current state of the application cache that the ApplicationCache object's cache host is associated with, if any.
This must be the appropriate value from the following list:
  • UNCACHED (numeric value 0)
  • IDLE (numeric value 1)
  • CHECKING (numeric value 2)
  • DOWNLOADING (numeric value 3)
  • UPDATEREADY (numeric value 4)
  • OBSOLETE (numeric value 5)
  •  - BlackBerry OS 6.0+
     - BlackBerry PlayBook
     - Ripple Emulator

    Code Example(s)

    var appCache = window.applicationCache;
    switch (appCache.status) {
    case appCache.UNCACHED:    // UNCACHED == 0
    	return 'UNCACHED';
    	break;
    case appCache.IDLE: 		  // IDLE == 1
    	return 'IDLE'; 
    	break;
    case appCache.CHECKING:    // CHECKING == 2
    	return 'CHECKING';
    	break;
    case appCache.DOWNLOADING: // DOWNLOADING == 3
    	return 'DOWNLOADING';
    	break;
    case appCache.UPDATEREADY: // UPDATEREADY == 5
    	return 'UPDATEREADY';
    	break;
    case appCache.OBSOLETE:    // OBSOLETE == 5
    	return 'OBSOLETE';
    	break;
    default:
    	return 'UKNOWN CACHE STATUS';
    	break;
    };

    Constants:


    Property Type Description Supported Platform(s)
    UNCACHED default: 0 Number The ApplicationCache object's cache host is not associated with an application cache at this time.
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook
     - Ripple Emulator
    IDLE default: 1 Number The ApplicationCache object's cache host is associated with an application cache whose application cache group's update status is idle, and that application cache is the newest cache in its application cache group, and the application cache group is not marked as obsolete.
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook
     - Ripple Emulator
    CHECKING default: 2 Number The ApplicationCache object's cache host is associated with an application cache whose application cache group's update status is checking.
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook
     - Ripple Emulator
    DOWNLOADING default: 3 Number The ApplicationCache object's cache host is associated with an application cache whose application cache group's update status is downloading.
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook
     - Ripple Emulator
    UPDATEREADY default: 4 Number The ApplicationCache object's cache host is associated with an application cache whose application cache group's update status is idle, and whose application cache group is not marked as obsolete, but that application cache is not the newest cache in its group.
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook
     - Ripple Emulator
    OBSOLETE default: 5 Number The ApplicationCache object's cache host is associated with an application cache whose application cache group is marked as obsolete.
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook
     - Ripple Emulator

    Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 30 2012 13:31:15 GMT-0500 (EST)