keys()
方法在
缓存
interface returns a
Promise
that resolves to an array of
缓存
键。
The requests are returned in the same order that they were inserted.
注意
: Requests with duplicate URLs but different headers can be returned if their responses have the
VARY
header set on them.
cache.keys(request, {options}).then(function(keys) {
// do something with your array of requests
});
Request
want to return, if a specific key is desired. This can be a
Request
object or a URL.
keys
operation. 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. In other words, if the URL matches you will get a match regardless of whether the
响应
对象拥有
VARY
header. It defaults to
false
.
cacheName
: A
DOMString
that represents a specific cache to search within. Note that this option is ignored by
Cache.keys()
.
A
Promise
that resolves to an array of
缓存
键。
caches.open('v1').then(function(cache) {
cache.keys().then(function(keys) {
keys.forEach(function(request, index, array) {
cache.delete(request);
});
});
})
| 规范 | 状态 | 注释 |
|---|---|---|
|
服务工作者
The definition of 'Cache: keys' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
keys
|
Chrome 43 | Edge 16 |
Firefox
39
注意事项
|
IE 不支持 No | Opera 30 | Safari 11 | WebView Android 43 | Chrome Android 43 | Firefox Android 39 | Opera Android 30 | Safari iOS 11 | Samsung Internet Android 4.0 |
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
缓存
CacheStorage
Client
Clients
ExtendableEvent
FetchEvent
InstallEvent
Navigator.serviceWorker
NotificationEvent
PeriodicSyncEvent
PeriodicSyncManager
PeriodicSyncRegistration
ServiceWorker
ServiceWorkerContainer
ServiceWorkerGlobalScope
ServiceWorkerRegistration
SyncEvent
SyncManager
SyncRegistration
WindowClient