import { CacheableResponsePlugin } from 'workbox-cacheable-response'; import { clientsClaim } from 'workbox-core'; import { registerRoute } from 'workbox-routing'; import { StaleWhileRevalidate } from 'workbox-strategies'; declare let self: ServiceWorkerGlobalScope; const cacheName = 'pages-cache'; self.addEventListener('install', () => { self.skipWaiting(); }); clientsClaim(); registerRoute( ({ request }) => request.destination === 'document', new StaleWhileRevalidate({ cacheName, plugins: [ new CacheableResponsePlugin({ statuses: [200], }), ], }) );