1const options = {"autoRegister":true,"cacheOptions":{"directoryIndex":"/","revision":"8OVLl011BSrb"},"enabled":true,"preCaching":[],"templatePath":null,"workboxVersion":"6.5.3","workboxUrl":"https://storage.googleapis.com/workbox-cdn/releases/6.5.3/workbox-sw.js"} 2 3importScripts(options.workboxUrl) 4 5self.addEventListener('install', () => self.skipWaiting()) 6self.addEventListener('activate', () => self.clients.claim()) 7 8const { registerRoute } = workbox.routing 9const { NetworkFirst, StaleWhileRevalidate, CacheFirst } = workbox.strategies 10const { CacheableResponsePlugin } = workbox.cacheableResponse 11const { ExpirationPlugin } = workbox.expiration 12const { precacheAndRoute } = workbox.precaching 13 14// Cache page navigations (html) with a Network First strategy 15registerRoute( 16 ({ request }) => { 17 return request.mode === 'navigate' 18 }, 19 new NetworkFirst({ 20 cacheName: 'pages', 21 plugins: [ 22 new CacheableResponsePlugin({ statuses: [200] }) 23 ] 24 }) 25) 26 27// Cache Web Manifest, CSS, JS, and Web Worker requests with a Stale While Revalidate strategy 28registerRoute( 29 ({ request }) => 30 request.destination === 'manifest' || 31 request.destination === 'style' || 32 request.destination === 'script' || 33 request.destination === 'worker', 34 new StaleWhileRevalidate({ 35 cacheName: 'assets', 36 plugins: [ 37 new CacheableResponsePlugin({ statuses: [200] }) 38 ] 39 }) 40) 41 42// Cache images with a Cache First strategy 43registerRoute( 44 ({ request }) => request.destination === 'image', 45 new CacheFirst({ 46 cacheName: 'images', 47 plugins: [ 48 new CacheableResponsePlugin({ statuses: [200] }), 49 // 50 entries max, 30 days max 50 new ExpirationPlugin({ maxEntries: 50, maxAgeSeconds: 60 * 60 * 24 * 30 }) 51 ] 52 }) 53) 54 55// Precaching 56if (options.preCaching.length) { 57 precacheAndRoute(options.preCaching, options.cacheOptions) 58}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.