CacheStorage class

The interface represents the storage for Cache objects. The interface:

Provides a master directory of all the named caches that can be accessed by a ServiceWorker or other type of worker or window scope (you’re not limited to only using it with service workers).

Note: Chrome and Safari only expose `CacheStorage` to the

windowed context over HTTPS. caches will be undefined unless an SSL certificate is configured.

Maintains a mapping of string names to corresponding Cache objects.

Use CacheStorage.open() to obtain a Cache instance. Use CacheStorage.match() to check if a given Request is a key in any of the Cache objects that the object tracks. You can access through the global caches property.

Note: always rejects with a SecurityError on untrusted origins (i.e. those that aren't using HTTPS, although this definition will likely become more complex in the future.) When testing on Firefox, you can get around this by checking the Enable Service Workers over HTTP (when toolbox is open) option in the Firefox Devtools options/gear menu. Furthermore, because requires file-system access, it may be unavailable in private mode in Firefox. Note: CacheStorage.match() is a convenience method. Equivalent functionality to match a cache entry can be implemented by returning an array of cache names from CacheStorage.keys(), opening each cache with CacheStorage.open(), and matching the one you want with Cache.match().

Note: This feature is available in Web Workers

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Available extensions
Annotations
  • @experimental
  • @JS()
  • @staticInterop

Constructors

CacheStorage()
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited