MDN wants to learn about developers like you:


This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The match() method of the CacheStorage interface checks if a given Request is a key in any of the Cache objects that the CacheStorage object tracks and returns a Promise that resolves to the matching Response.

Cache objects are searched by key insertion order.

Note: CacheStorage.match() is a convenience method. Equivalent functionality to match a cache entry can be implemented by opening your cache with, returning the entries it contains with CacheStorage.keys(), and matching the one you want with Cache.match().


cacheStorage.match(request, {options}).then(function(response) {
  // Do something with the request


The Request you want to match.  This can be a  Request object or a URL.
options Optional
An object whose properties control how matching is done in the match operation. The available options are:
  • ignoreSearch: A Boolean that specifies whether the matching process should ignore the query string in the url.  For example, if set to true, the ?value=bar part of would be ignored when performing a match. It defaults to false.
  • ignoreMethod: A Boolean that, when set to true, prevents matching operations from validating the Request http method (normally only GET and HEAD are allowed.) It defaults to false.
  • ignoreVary: A Boolean that, when set to true, tells the matching operation not to perform VARY header matching. In other words, if the URL matches you will get a match regardless of whether the Response object has a VARY header or not. It defaults to false.
  • cacheName: A DOMString that represents a specific cache to search within.

Return value

a Promise that resolves to the matching Response. If no matching response to the specified request is found, the promise resolves with undefined.


This example is from the MDN sw-test example (see sw-test running live). Here we wait for a FetchEvent to fire. We construct a custom response like so:

  1. Check whether a match for the request is found in the CacheStorage using CacheStorage.match(). If so, serve that.
  2. If not, open the v1 cache using open(), put the default network request in the cache using Cache.put() and return a clone of the default network request using return response.clone(). The last is necessary because put() consumes the response body.
  3. If this fails (e.g., because the network is down), return a fallback response.
caches.match(event.request).then(function(response) {
  return response || fetch(event.request).then(function(r) {'v1').then(function(cache) {
      cache.put(event.request, r);
    return r.clone();
}).catch(function() {
  return caches.match('/sw-test/gallery/myLittleVader.jpg');


Specification Status Comment
Service Workers
The definition of 'CacheStorage' in that specification.
Editor's Draft Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 40[1] 44 (44)[2] No support 27 No support
All options supported 54 (Yes) No support 41 No support
Feature Android Webview Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 40[1] 40[1] 44.0 (44) (Yes) 27 (Yes)
All options supported 54 54 (Yes) (Yes) 41 (Yes)

See also

Document Tags and Contributors

 Contributors to this page: jpmedley, tomayac, robbiejaeger, chrisdavidmills, ebidel, kscarfone
 Last updated by: jpmedley,