Chrome Dev Summit 2020 is back & going virtual on December 9-10. Learn more

Class: NetworkOnly

Constructor

NetworkOnly

new NetworkOnly(options)

Parameter

options

Optional

Object

Values in options have the following properties:

Parameter

plugins

Optional

Array of Object

Plugins to use in conjunction with this caching strategy.

fetchOptions

Optional

Object

Values passed along to the init of all fetch() requests made by this strategy.

networkTimeoutSeconds

Optional

number

If set, any network requests that fail to respond within the timeout will result in a network error.

Extends
module:workbox-strategies.Strategy

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 FetchEvent or an object with the properties listed below.

Values in options have the following properties:

Parameter

request

A request to run this strategy for.

event

The event associated with the request.

url

Optional

params

Optional

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 FetchEvent or an object with the properties listed below.

Values in options have the following properties:

Parameter

request

A request to run this strategy for.

event

The event associated with the request.

url

Optional

params

Optional

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.