add method

JSPromise<JSAny?> add(
  1. RequestInfo request
)

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

The add() method is functionally equivalent to the following:

fetch(url).then((response) => {
  if (!response.ok) {
    throw new TypeError("bad response status");
  }
  return cache.put(url, response);
});

For more complex operations, you'll need to use Cache.put directly.

Note: add() will overwrite any key/value pair previously stored in the cache that matches the request.

Implementation

external JSPromise<JSAny?> add(RequestInfo request);