Constructor

Plugin

new Plugin(config)

Parameter

config

Object

Values in config have the following properties:

Parameter

maxEntries

Optional

number

The maximum number of entries to cache. Entries used the least will be removed as the maximum is reached.

maxAgeSeconds

Optional

number

The maximum age of an entry before it's treated as stale and removed.

purgeOnQuotaError

Optional

boolean

Whether to opt this cache in to automatic deletion if the available storage quota has been exceeded.

Method

deleteCacheAndMetadata

async

deleteCacheAndMetadata()

This is a helper method that performs two operations:

  • Deletes all the underlying Cache instances associated with this plugin instance, by calling caches.delete() on you behalf.
  • Deletes the metadata from IndexedDB used to keep track of expiration details for each Cache instance.

When using cache expiration, calling this method is preferable to calling caches.delete() directly, since this will ensure that the IndexedDB metadata is also cleanly removed and open IndexedDB instances are deleted.

Note that if you're not using cache expiration for a given cache, calling caches.delete() and passing in the cache's name should be sufficient. There is no Workbox-specific method needed for cleanup in that case.