CacheStorage

interface

interface CacheStorage

Represents the storage for named Cache objects. It provides the methods used to open, enumerate, look up, and delete caches, and is accessed via the global caches property.

variable

var CacheStorage: { … }

The constructor object for CacheStorage.

The CacheStorage instance is accessed via the global caches property rather than constructed directly, so calling the constructor throws.

Constructors

constructor

new CacheStorage(): never

Properties

prototype

readonly prototype: CacheStorage

Methods

open

open(cacheName: string): Promise<Cache>

Open a cache storage for the provided name.

has

has(cacheName: string): Promise<boolean>

Check if cache already exists for the provided name.

delete

delete(cacheName: string): Promise<boolean>

Delete cache storage for the provided name.

keys

keys(): Promise<string[]>

Return an array of all cache names tracked by the cache storage.

match

match(request: RequestInfo | URL, options?: MultiCacheQueryOptions): Promise<Response | undefined>

Check if a given Request or URL string is a key for a stored Response. Returns the matching Response, or undefined if no match is found.

If options.cacheName is provided, only the cache with that name is searched. Otherwise, all caches are searched in creation order.