Back to Content

StorageAccessHandle: caches property

files/en-us/web/api/storageaccesshandle/caches/index.md

latest930 B
Original Source

{{APIRef("Storage Access API")}}

The caches property of the {{domxref("StorageAccessHandle")}} interface returns an unpartitioned {{domxref("CacheStorage")}} object if access was granted, and throws a SecurityError {{DOMxRef("DOMException")}} otherwise.

Value

A {{domxref("CacheStorage")}} object.

Examples

js
document.requestStorageAccess({ caches: true }).then(
  (handle) => {
    console.log("caches access granted");
    const cache = await handle.caches.open("foo");
    await cache.add("/");
  },
  () => {
    console.log("caches access denied");
  },
);

[!NOTE] See Using the Storage Access API for a more complete example.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also