Constructor

StaleWhileRevalidate

new StaleWhileRevalidate(input)

Constructor for a new StaleWhileRevalidate instance.

Parameter

input

Object

Extends
module:workbox-runtime-caching.Handler

Example

// Set up a route to match any requests made for URLs that end in .txt.
// The requests are handled with a stale-while-revalidate strategy.
const route = new workbox.routing.RegExpRoute({
  regExp: /\.txt$/,
  handler: new workbox.runtimeCaching.StaleWhileRevalidate(),
});

const router = new workbox.routing.Router();
router.registerRoute({route});

Method

handle

async

handle(input) returns Promise containing Response

The handle method will be called by the Route class when a route matches a request.

Parameter

input

Object

Returns

Promise containing Response The response from the cache, if present, or from the network if not.