Adds a fetch event listener that serves content from the browser cache when available. When
a request is not in the cache, it will be fetched from the network and added to the
cache if the route has browser.serviceWorkerSeconds
defined in its cache
setting or if the
request is a prefetch.
Transform method from HTTPMethod type to uppercase HTTPMethod type from workbox the way typescript tolerates
Generated using TypeDoc
Handles prefetching and caching in the the service worker. Responses are cached based on the
browser.serviceWorkerSeconds
cache setting in your routes.Example routes.js
import { Router } from '@edgio/core/router' module.exports = new Router() .match('/some/path', ({ cache }) => { cache({ edge: { maxAgeSeconds: 60 * 60 * 24 // one day }, browser: { serviceWorkerSeconds: 60 * 60 // one hour } }) })
Example Service Worker
import { skipWaiting, clientsClaim } from 'workbox-core' import { Prefetcher } from '@edgio/prefetch/sw' import { precacheAndRoute } from 'workbox-precaching' skipWaiting() clientsClaim() precacheAndRoute(self.__WB_MANIFEST || []) new Prefetcher().route()