Cache

interface

interface Cache

Represents a single named store of Request/Response pairs. Obtain a Cache via CacheStorage.open and use it to persist responses and later match incoming requests against them.

variable

var Cache: { … }

The constructor object for Cache.

Cache instances are obtained via CacheStorage.open rather than constructed directly, so calling the constructor throws.

Constructors

constructor

new Cache(): never

Properties

prototype

readonly prototype: Cache

Methods

put

put(request: RequestInfo | URL, response: Response): Promise<void>

Put the provided request/response into the cache.

How is the API different from browsers?

  1. You cannot match cache objects using relative paths.
  2. You cannot pass options like ignoreVary, ignoreMethod, ignoreSearch.

match

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

Return cache object matching the provided request.

How is the API different from browsers?

  1. You cannot match cache objects using relative paths.
  2. You cannot pass options like ignoreVary, ignoreMethod, ignoreSearch.

delete

delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>

Delete cache object matching the provided request.

How is the API different from browsers?

  1. You cannot delete cache objects using relative paths.
  2. You cannot pass options like ignoreVary, ignoreMethod, ignoreSearch.

keys

keys(request?: RequestInfo | URL, options?: CacheQueryOptions): Promise<ReadonlyArray<Request>>

Return the Request keys stored in the cache, in insertion order. When a request is provided, only the matching keys are returned.

How is the API different from browsers?

  1. You cannot match cache objects using relative paths.
  2. You cannot pass options like ignoreVary, ignoreMethod, ignoreSearch.