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
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.
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. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
matchAll
|
Chrome 47 | Edge 16 |
Firefox
39
注意事项
|
IE 不支持 No |
Opera
34
注意事项
|
Safari 11 | WebView Android 47 | Chrome Android 47 | Firefox Android 39 | Opera Android 34 | Safari iOS 11 | Samsung Internet Android 5.0 |
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
缓存
CacheStorage
Client
Clients
ExtendableEvent
FetchEvent
InstallEvent
Navigator.serviceWorker
NotificationEvent
PeriodicSyncEvent
PeriodicSyncManager
PeriodicSyncRegistration
ServiceWorker
ServiceWorkerContainer
ServiceWorkerGlobalScope
ServiceWorkerRegistration
SyncEvent
SyncManager
SyncRegistration
WindowClient