1importScripts('https://cdn.jsdelivr.net/npm/[email protected]/workbox/workbox-sw.js') 2 3workbox.setConfig({ 4 "debug": false 5}); 6// Start controlling any existing clients as soon as it activates 7workbox.core.clientsClaim() 8 9// Skip over the SW waiting lifecycle stage 10workbox.core.skipWaiting() 11 12workbox.precaching.cleanupOutdatedCaches() 13 14 15 workbox.routing.registerRoute( 16 new RegExp('https://static\.olansies\.com/.*(?:png|gif|jpg|jpeg|webp|svg)$'), 17 new workbox.strategies.CacheFirst({ 18 cacheName: 'cdn:images', 19 plugins: [ 20 new workbox.cacheableResponse.Plugin({ 21 statuses: [0, 200] 22 }), 23 new workbox.expiration.Plugin({ 24 maxEntries: 30, 25 maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days 26 }), 27 ], 28 }) 29 ); 30 workbox.routing.registerRoute( 31 new RegExp('https://static\.olansies\.com/.*(?:js|css)$'), 32 new workbox.strategies.StaleWhileRevalidate({ 33 cacheName: 'cdn:cssjs', 34 plugins: [ 35 new workbox.cacheableResponse.Plugin({ 36 statuses: [0, 200] 37 }), 38 new workbox.expiration.Plugin({ 39 maxEntries: 30, 40 maxAgeSeconds: 7 * 24 * 60 * 60, // 7 Days 41 }) 42 ] 43 }) 44 ); 45 46 47// Cache the Google Fonts stylesheets with a stale-while-revalidate strategy. 48workbox.routing.registerRoute( 49 /^https:\/\/fonts\.googleapis\.com/, 50 new workbox.strategies.StaleWhileRevalidate({ 51 cacheName: 'google-fonts-stylesheets', 52 }) 53); 54 55// Cache the underlying font files with a cache-first strategy for 1 year. 56workbox.routing.registerRoute( 57 /^https:\/\/fonts\.gstatic\.com/, 58 new workbox.strategies.CacheFirst({ 59 cacheName: 'google-fonts-webfonts', 60 plugins: [ 61 new workbox.cacheableResponse.Plugin({ 62 statuses: [0, 200], 63 }), 64 new workbox.expiration.Plugin({ 65 maxAgeSeconds: 60 * 60 * 24 * 365, 66 maxEntries: 30, 67 }), 68 ], 69 }) 70); 71 72 73workbox.routing.registerRoute( 74 /\.html$/, 75 new workbox.strategies.NetworkFirst ({ 76 networkTimeoutSeconds: 5, 77 cacheName:'html-caches', 78 plugins: [ 79 new workbox.cacheableResponse.Plugin({ 80 statuses: [0, 200] 81 }), 82 new workbox.expiration.Plugin({ 83 maxEntries: 30, 84 maxAgeSeconds: 10 * 60 * 60 85 }) 86 ] 87}), 'GET'); 88workbox.routing.registerRoute( 89 /\.(?:png|gif|jpg|jpeg|webp|svg)$/, 90 new workbox.strategies.CacheFirst({ 91 cacheName: 'images', 92 plugins: [ 93 new workbox.cacheableResponse.Plugin({ 94 statuses: [0, 200] 95 }), 96 new workbox.expiration.Plugin({ 97 maxEntries: 30, 98 maxAgeSeconds: 7 * 24 * 60 * 60, // 7 Days 99 }), 100 ], 101 }) 102);
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.