Join us online - 19th of November
Save your spot
For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.

Interface CacheStorage

The CacheStorage interface represents the storage for Cache objects. Available only in secure contexts.

MDN Reference

interface CacheStorage {
    delete(cacheName: string): Promise<boolean>;
    has(cacheName: string): Promise<boolean>;
    keys(): Promise<string[]>;
    match(
        request: RequestInfo | URL,
        options?: MultiCacheQueryOptions,
    ): Promise<Response | undefined>;
    open(cacheName: string): Promise<Cache>;
}
Index
  • The delete() method of the CacheStorage interface finds the Cache object matching the cacheName, and if found, deletes the Cache object and returns a Promise that resolves to true. If no Cache object is found, it resolves to false.

    MDN Reference

    Parameters

    • cacheName: string

    Returns Promise<boolean>

  • The has() method of the CacheStorage interface returns a Promise that resolves to true if a Cache object matches the cacheName.

    MDN Reference

    Parameters

    • cacheName: string

    Returns Promise<boolean>

  • The keys() method of the CacheStorage interface returns a Promise that will resolve with an array containing strings corresponding to all of the named Cache objects tracked by the CacheStorage object in the order they were created. Use this method to iterate over a list of all Cache objects.

    MDN Reference

    Returns Promise<string[]>

  • The match() method of the CacheStorage interface checks if a given Request or URL string is a key for a stored Response. This method returns a Promise for a Response, or a Promise which resolves to undefined if no match is found.

    MDN Reference

    Parameters

    Returns Promise<Response | undefined>

  • The open() method of the CacheStorage interface returns a Promise that resolves to the Cache object matching the cacheName.

    MDN Reference

    Parameters

    • cacheName: string

    Returns Promise<Cache>

Was this helpful?