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 1.0+
- BlackBerry 10
- Ripple Emulator
View Supported Platform Table
APIBB5.0BB6.0BB7.0PB1.0PB2.0BB10Ripple
window.applicationCache   Y Y Y Y YY
worker.applicationCache   Y Y Y Y YY
swapCache   Y Y Y Y YY
update   Y Y Y Y YY
status   Y Y Y Y YY
UNCACHED   Y Y Y Y YY
IDLE   Y Y Y Y YY
CHECKING   Y Y Y Y YY
DOWNLOADING   Y Y Y Y YY
UPDATEREADY   Y Y Y Y YY
OBSOLETE   Y Y Y Y YY
cached   Y Y Y Y YY
checking   Y Y Y Y YY
downloading   Y Y Y Y YY
error   Y Y Y Y YY
noupdate   Y Y Y Y YY
obsolete   Y Y Y Y YY
progress   Y Y Y Y YY
updateready   Y Y 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 and BlackBerry 10+)
This API does not require a <permission> element to be declared in the configuration document of your BlackBerry WebWorks Application.


Functions

void swapCache
void update

Events

void cached
void checking
void downloading
void error
void noupdate
void obsolete
void progress
void updateready

Properties

Number status

Constants

Number UNCACHED
Number IDLE
Number CHECKING
Number DOWNLOADING
Number UPDATEREADY
Number OBSOLETE

Constructors

window.applicationCache


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


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


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

worker.applicationCache


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


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


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

doWork.js (the worker):

  var appCache = self.applicationCache()

Functions

void swapCache ()


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.


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


Throws
INVALID_STATE_ERR If the current app cache is the most recent

Code Example:
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.
}

void update ()


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


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


Code Example:
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.
}

Events

void cached ()


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


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


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

void checking ()


Sent when the cache update process begins.


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


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

void downloading ()


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


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


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

void error ()


Sent when an error occurs.


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


Code Example:
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);

void noupdate ()


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


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


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

void obsolete ()


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


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


Code Example:
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);

void progress ()


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


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


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

void updateready ()


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


Supported Platforms
 - BlackBerry OS 6.0+
 - BlackBerry PlayBook 1.0+
 - BlackBerry 10
 - Ripple Emulator


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

Properties

Number status


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)


    Supported Platforms
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook 1.0+
     - BlackBerry 10
     - Ripple Emulator


    Code Example:
    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

    static Number UNCACHED = 0


    The ApplicationCache object's cache host is not associated with an application cache at this time.


    Supported Platforms
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook 1.0+
     - BlackBerry 10
     - Ripple Emulator

    static Number IDLE = 1


    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.


    Supported Platforms
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook 1.0+
     - BlackBerry 10
     - Ripple Emulator

    static Number CHECKING = 2


    The ApplicationCache object's cache host is associated with an application cache whose application cache group's update status is checking.


    Supported Platforms
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook 1.0+
     - BlackBerry 10
     - Ripple Emulator

    static Number DOWNLOADING = 3


    The ApplicationCache object's cache host is associated with an application cache whose application cache group's update status is downloading.


    Supported Platforms
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook 1.0+
     - BlackBerry 10
     - Ripple Emulator

    static Number UPDATEREADY = 4


    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.


    Supported Platforms
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook 1.0+
     - BlackBerry 10
     - Ripple Emulator

    static Number OBSOLETE = 5


    The ApplicationCache object's cache host is associated with an application cache whose application cache group is marked as obsolete.


    Supported Platforms
     - BlackBerry OS 6.0+
     - BlackBerry PlayBook 1.0+
     - BlackBerry 10
     - Ripple Emulator

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