Chartbreaker
    Preparing search index...

    Interface Cache

    The Cache interface provides a persistent storage mechanism for Request / Response object pairs that are cached in long lived memory. How long a Cache object lives is browser dependent, but a single origin's scripts can typically rely on the presence of a previously populated Cache object. Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec. Available only in secure contexts.

    MDN Reference

    interface Cache {
        add(request: URL | RequestInfo): Promise<void>;
        addAll(requests: RequestInfo[]): Promise<void>;
        addAll(requests: Iterable<RequestInfo>): Promise<void>;
        delete(
            request: URL | RequestInfo,
            options?: CacheQueryOptions,
        ): Promise<boolean>;
        keys(
            request?: URL | RequestInfo,
            options?: CacheQueryOptions,
        ): Promise<readonly Request[]>;
        match(
            request: URL | RequestInfo,
            options?: CacheQueryOptions,
        ): Promise<Response | undefined>;
        matchAll(
            request?: URL | RequestInfo,
            options?: CacheQueryOptions,
        ): Promise<readonly Response[]>;
        put(request: URL | RequestInfo, response: Response): Promise<void>;
    }
    Index

    Methods

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

      MDN Reference

      Parameters

      Returns Promise<void>

    • The addAll() method of the Cache interface takes an array of URLs, retrieves them, and adds the resulting response objects to the given cache. The request objects created during retrieval become keys to the stored response operations.

      MDN Reference

      Parameters

      Returns Promise<void>

    • The addAll() method of the Cache interface takes an array of URLs, retrieves them, and adds the resulting response objects to the given cache. The request objects created during retrieval become keys to the stored response operations.

      MDN Reference

      Parameters

      Returns Promise<void>

    • 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. If no Cache entry is found, it resolves to false.

      MDN Reference

      Parameters

      Returns Promise<boolean>

    • The keys() method of the Cache interface returns a Promise that resolves to an array of Request objects representing the keys of the Cache.

      MDN Reference

      Parameters

      Returns Promise<readonly Request[]>

    • 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. If no match is found, the Promise resolves to undefined.

      MDN Reference

      Parameters

      Returns Promise<Response | undefined>

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

      MDN Reference

      Parameters

      Returns Promise<readonly Response[]>

    • The put() method of the Cache interface allows key/value pairs to be added to the current Cache object.

      MDN Reference

      Parameters

      Returns Promise<void>