Module: workbox-core

Property

cacheNames

constant   static

Get the current cache names and prefix/suffix used by Workbox.

cacheNames.precache is used for precached assets, cacheNames.googleAnalytics is used by workbox-google-analytics to store analytics.js, and cacheNames.runtime is used for everything else.

cacheNames.prefix can be used to retrieve just the current prefix value. cacheNames.suffix can be used to retrieve just the current suffix value.

Returns

Object An object with precache, runtime, prefix, and googleAnalytics properties.

Methods

clientsClaim

static

clientsClaim()

Claim any currently available clients once the service worker becomes active. This is normally used in conjunction with skipWaiting().

copyResponse

async   static

copyResponse(response, modifier)

Allows developers to copy a response and modify its headers, status, or statusText values (the values settable via a ResponseInit object in the constructor). To modify these values, pass a function as the second argument. That function will be invoked with a single object with the response properties {headers, status, statusText}. The return value of this function will be used as the ResponseInit for the new Response. To change the values either modify the passed parameter(s) and return it, or return a totally new object.

Parameter

response

Response

modifier

function()

registerQuotaErrorCallback

static

registerQuotaErrorCallback(callback)

Adds a function to the set of quotaErrorCallbacks that will be executed if there's a quota error.

Parameter

callback

function()

setCacheNameDetails

static

setCacheNameDetails(details)

Modifies the default cache names used by the Workbox packages. Cache names are generated as <prefix>-<Cache Name>-<suffix>.

Parameter

details

Object

Values in details have the following properties:

Parameter

prefix

Optional

Object

The string to add to the beginning of the precache and runtime cache names.

suffix

Optional

Object

The string to add to the end of the precache and runtime cache names.

precache

Optional

Object

The cache name to use for precache caching.

runtime

Optional

Object

The cache name to use for runtime caching.

googleAnalytics

Optional

Object

The cache name to use for workbox-google-analytics caching.

skipWaiting

static

skipWaiting()

Force a service worker to activate immediately, instead of waiting for existing clients to close.