Cache

class Cache(source)

The Cache interface provides a persistent storage mechanism for Request / Response object pairs that are cached in long lived memory. Available only in secure contexts.

MDN Reference

Functions

Link copied to clipboard
suspend fun add(url: String)

The add() method of the Cache interface takes a URL, retrieves it, and adds the resulting response object to the given cache.

suspend fun add(request: Request)
suspend fun add(url: URL)
Link copied to clipboard
suspend fun addAll(urls: ReadonlyArray<JsString>)

suspend fun addAll(requests: ReadonlyArray<Request>)

The addAll() method of the Cache interface takes an array of URLs, retrieves them, and adds the resulting response objects to the given cache.

Link copied to clipboard
Link copied to clipboard
fun addAsync(request: Request): Promise<Void>
fun addAsync(url: URL): Promise<Void>
Link copied to clipboard
suspend fun delete(url: String, options: CacheQueryOptions = definedExternally): Boolean

The delete() method of the Cache interface finds the Cache entry whose key is the request, and if found, deletes the Cache entry and returns a Promise that resolves to true.

suspend fun delete(request: Request, options: CacheQueryOptions = definedExternally): Boolean
suspend fun delete(url: URL, options: CacheQueryOptions = definedExternally): Boolean
Link copied to clipboard
fun deleteAsync(url: String, options: CacheQueryOptions = definedExternally): Promise<JsBoolean>
fun deleteAsync(request: Request, options: CacheQueryOptions = definedExternally): Promise<JsBoolean>
fun deleteAsync(url: URL, options: CacheQueryOptions = definedExternally): Promise<JsBoolean>
Link copied to clipboard
suspend fun keys(url: String = definedExternally, options: CacheQueryOptions = definedExternally): ReadonlyArray<Request>

The keys() method of the Cache interface returns a representing the keys of the Cache.

suspend fun keys(request: Request, options: CacheQueryOptions = definedExternally): ReadonlyArray<Request>
suspend fun keys(url: URL, options: CacheQueryOptions = definedExternally): ReadonlyArray<Request>
Link copied to clipboard
fun keysAsync(url: String = definedExternally, options: CacheQueryOptions = definedExternally): Promise<ReadonlyArray<Request>>
fun keysAsync(request: Request, options: CacheQueryOptions = definedExternally): Promise<ReadonlyArray<Request>>
fun keysAsync(url: URL, options: CacheQueryOptions = definedExternally): Promise<ReadonlyArray<Request>>
Link copied to clipboard
suspend fun match(url: String, options: CacheQueryOptions = definedExternally): Response?

The match() method of the Cache interface returns a Promise that resolves to the Response associated with the first matching request in the Cache object.

suspend fun match(request: Request, options: CacheQueryOptions = definedExternally): Response?
suspend fun match(url: URL, options: CacheQueryOptions = definedExternally): Response?
Link copied to clipboard
suspend fun matchAll(url: String = definedExternally, options: CacheQueryOptions = definedExternally): ReadonlyArray<Response>

The matchAll() method of the Cache interface returns a Promise that resolves to an array of all matching responses in the Cache object.

suspend fun matchAll(request: Request, options: CacheQueryOptions = definedExternally): ReadonlyArray<Response>
suspend fun matchAll(url: URL, options: CacheQueryOptions = definedExternally): ReadonlyArray<Response>
Link copied to clipboard
fun matchAllAsync(url: String = definedExternally, options: CacheQueryOptions = definedExternally): Promise<ReadonlyArray<Response>>
fun matchAllAsync(request: Request, options: CacheQueryOptions = definedExternally): Promise<ReadonlyArray<Response>>
fun matchAllAsync(url: URL, options: CacheQueryOptions = definedExternally): Promise<ReadonlyArray<Response>>
Link copied to clipboard
fun matchAsync(url: String, options: CacheQueryOptions = definedExternally): Promise<Response?>
fun matchAsync(request: Request, options: CacheQueryOptions = definedExternally): Promise<Response?>
fun matchAsync(url: URL, options: CacheQueryOptions = definedExternally): Promise<Response?>
Link copied to clipboard
suspend fun put(url: String, response: Response)

The put() method of the Often, you will just want to Window/fetch one or more requests, then add the result straight to your cache.

suspend fun put(request: Request, response: Response)
suspend fun put(url: URL, response: Response)
Link copied to clipboard
fun putAsync(url: String, response: Response): Promise<Void>
fun putAsync(request: Request, response: Response): Promise<Void>
fun putAsync(url: URL, response: Response): Promise<Void>