1importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js'); 2 3if (workbox) { 4 console.log("Yay! Workbox is loaded"); 5} else { 6 console.log("Boo! Workbox didn't load"); 7} 8 9workbox.precaching.precacheAndRoute([ 10 { url: './css/app.css', revision: '10000378' }, 11 { url: './css/sunburst.css', revision: '10000378' }, 12 { url: 'app.js', revision: '10000380' }, 13 { url: './index.html', revision: '10000378' }, 14 { url: './images/user.jpg', revision: '10000378' }, 15 { url: './images/chatbot.jpg', revision: '10000378' } 16]); 17 18workbox.routing.registerRoute( 19 new RegExp('.*\.js'), 20 workbox.strategies.networkFirst() 21); 22 23workbox.routing.registerRoute( 24 // Cache CSS files 25 /.*\.css/, 26 // Use cache but update in the background ASAP 27 workbox.strategies.staleWhileRevalidate({ 28 // Use a custom cache name 29 cacheName: 'css-cache', 30 }) 31); 32 33workbox.routing.registerRoute( 34 // Cache image files 35 /.*\.(?:png|jpg|jpeg|svg|gif|ico)/, 36 // Use the cache if it's available 37 workbox.strategies.cacheFirst({ 38 // Use a custom cache name 39 cacheName: 'image-cache', 40 plugins: [ 41 new workbox.expiration.Plugin({ 42 // Cache only 20 images 43 maxEntries: 20, 44 // Cache for a maximum of a week 45 maxAgeSeconds: 7 * 24 * 60 * 60, 46 }) 47 ], 48 }) 49);
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.