matchAll() 方法在 缓存 interface returns a Promise that resolves to an array of all matching responses in the 缓存 对象。

句法

cache.matchAll(request, {options}).then(function(response) {
  // do something with the response array
});
					

参数

request 可选
Request for which you are attempting to find responses in the 缓存 . This can be a Request object or a URL. If this argument is omitted, you will get a copy of all responses in this cache.
选项 可选
An options object allowing you to set specific control options for the matching performed. The available options are:
  • ignoreSearch : A 布尔 that specifies whether the matching process should ignore the query string in the url.  If set to true ?value=bar 部分在 http://foo.com/?value=bar would be ignored when performing a match. It defaults to false .
  • ignoreMethod : A 布尔 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 布尔 that when set to true tells the matching operation not to perform VARY header matching — i.e. if the URL matches you will get a match regardless of the 响应 object having a VARY header or not. It defaults to false .

返回值

A Promise that resolves to an array of all matching responses in the 缓存 对象。

注意 : Cache.match() is basically identical to Cache.matchAll() , except that rather than resolving with an array of all matching responses, it resolves with the first matching response only (that is, response [0] ).

范例

caches.open('v1').then(function(cache) {
  cache.matchAll('/images/').then(function(response) {
    response.forEach(function(element, index, array) {
      cache.delete(element);
    });
  });
})
					

规范

规范 状态 注释
服务工作者
The definition of 'Cache: matchAll' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
matchAll Chrome 47 Edge 16 Firefox 39 注意事项
39 注意事项
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
IE 不支持 No Opera 34 注意事项
34 注意事项
Requires HTTPS.
Safari 11 WebView Android 47 Chrome Android 47 Firefox Android 39 Opera Android 34 Safari iOS 11 Samsung Internet Android 5.0

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

见实现注意事项。

另请参阅

元数据

  • 最后修改: