Constructor

new NavigationRoute(input)

Constructor for NavigationRoute.

Parameter

input

Object

Values in input have the following properties:

Parameter

whitelist

Array of RegExp

If any of these patterns match, the route will handle the request (assuming the blacklist doesn't match).

blacklist

Optional

Array of RegExp

If any of these patterns match, the route will not handle the request (even if a whitelist entry matches).

handler

(function() or module:workbox-runtime-caching.Handler)

The handler to use to provide a response if the route matches.

If you wish to use a callback function see handlerCallback for the callback definition.

Extends
Route

Example

// Any navigation requests that match the whitelist (i.e. URLs whose path
// starts with /article/) will be handled with the cache entry for
// app-shell.html.
const route = new workbox.routing.NavigationRoute({
  whitelist: [new RegExp('^/article/')],
  handler: {handle: () => caches.match('app-shell.html')},
});

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