cache.match()
The match method has two parameters, a request object and an optional options object. It returns a promise if a matching response is found to be resolved in the promise's return. If no response was found, the promise still resolves, but as undefined.
If no match was found, you can then continue with the appropriate logic, like forwarding the request to the network or returning a fallback response.
The request object parameter can be either a valid request object or a URL. If only a URL is provided, the method does an implicit conversion internally. Supplying a request object gives you more control because different responses could be cached by request variations.
For example, the same URL might have a cached response for both ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access