Constructor

PrecacheController

new PrecacheController(cacheName)

Create a new PrecacheController.

Parameter

cacheName

string

Methods

activate

async

activate(options) returns Promise containing workbox.precaching.CleanupResult

Takes the current set of temporary files and moves them to the final cache, deleting the temporary cache once copying is complete.

Parameter

options

Object

Values in options have the following properties:

Parameter

plugins

Array of Object

Plugins to be used for fetching and caching during install.

Returns

Promise containing workbox.precaching.CleanupResult Resolves with an object containing details of the deleted cache requests and precache revision details.

addToCacheList

addToCacheList(entries)

This method will add items to the precache list, removing duplicates and ensuring the information is valid.

Parameter

entries

Array of (module:workbox-precaching.PrecacheController.PrecacheEntry or string)

Array of entries to precache.

getCachedUrls

getCachedUrls() returns Array of string

Returns an array of fully qualified URL's that will be precached.

Returns

Array of string An array of URLs.

install

async

install(options) returns Promise containing workbox.precaching.InstallResult

Call this method from a service work install event to start precaching assets.

Parameter

options

Object

Values in options have the following properties:

Parameter

suppressWarnings

Optional

boolean

Suppress warning messages.

event

Optional

Event

The install event (if needed).

plugins

Optional

Array of Object

Plugins to be used for fetching and caching during install.

Returns

Promise containing workbox.precaching.InstallResult