workbox-strategies. CacheOnly
An implementation of a cache-only request strategy.
This class is useful if you want to take advantage of any Workbox plugins.
If there is no cache match, this will throw a WorkboxError
exception.
Constructor
CacheOnly
new CacheOnly()
Properties
cacheName
unknown
Cache name to store and retrieve requests. Defaults to the cache names provided by workbox-core.
- Inherited from
- module:workbox-strategies.Strategy#cacheName
fetchOptions
unknown
Values passed along to the
init
of all fetch() requests made by this strategy.
- Inherited from
- module:workbox-strategies.Strategy#fetchOptions
matchOptions
unknown
The
CacheQueryOptions
for any cache.match()
or cache.put()
calls made by this strategy.
- Inherited from
- module:workbox-strategies.Strategy#matchOptions
plugins
unknown
The list Plugins used by this strategy.
- Inherited from
- module:workbox-strategies.Strategy#plugins
Methods
handle
handle(options)
Perform a request strategy and returns a Promise
that will resolve with
a Response
, invoking all relevant plugin callbacks.
When a strategy instance is registered with a Workbox route, this method is automatically called when the route matches.
Alternatively, this method can be used in a standalone FetchEvent
listener by passing it to event.respondWith()
.
Parameter |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
A Values in
|
- Inherited from
- module:workbox-strategies.Strategy#handle
handleAll
handleAll(options) returns Array of Promise
Similar to handle()
, but
instead of just returning a Promise
that resolves to a Response
it
it will return an tuple of [response, done] promises, where the former
(response
) is equivalent to what handle()
returns, and the latter is a
Promise that will resolve once any promises that were added to
event.waitUntil()
as part of performing the strategy have completed.
You can await the done
promise to ensure any extra work performed by
the strategy (usually caching responses) completes successfully.
Parameter |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
A Values in
|
- Inherited from
- module:workbox-strategies.Strategy#handleAll
- Returns
-
A tuple of [response, done] promises that can be used to determine when the response resolves as well as when the handler has completed all its work.