此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Window:caches 属性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2018年4月⁩.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

Window 接口的 caches 只读属性返回与当前上下文相关联的 CacheStorage 对象。此对象提供了诸如存储用于离线使用的资源,并生成对请求的自定义响应等功能。

一个 CacheStorage 对象。

示例

以下示例展示了在窗口中应如何检索缓存数据。

js
window.caches.open("v1").then((cache) => {
  return cache.match("/list");
});

规范

Specification
Service Workers
# self-caches

浏览器兼容性

参见