1importScripts( 2 'https://storage.googleapis.com/workbox-cdn/releases/5.0.0/workbox-sw.js', 3); 4 5let FALLBACK_URL = '/offline'; 6let FALLBACK_IMG = '/themes/custom/diginomica_theme/images/pwa/placeholder.jpg'; 7let FALLBACK_PWA_IMG = [ 8 '/themes/custom/diginomica_theme/images/pwa/placeholder-pwa.webp', 9 '/themes/custom/diginomica_theme/images/pwa/placeholder-pwa.png', 10]; 11 12workbox.setConfig({ 13 debug: false, 14}); 15 16workbox.loadModule('workbox-cacheable-response'); 17workbox.loadModule('workbox-background-sync'); 18 19workbox.core.clientsClaim(); 20workbox.core.skipWaiting(); 21 22const bgSyncPlugin = new workbox.backgroundSync.BackgroundSyncPlugin( 23 'BGQueue', 24 { 25 maxRetentionTime: 24 * 60, 26 }, 27); 28 29workbox.precaching.precacheAndRoute([ 30 FALLBACK_IMG, 31 FALLBACK_URL, 32 ...FALLBACK_PWA_IMG, 33]); 34 35 36workbox.routing.registerRoute( 37 /.*/, 38 new workbox.strategies.NetworkOnly(), 39 'POST', 40); 41 42workbox.routing.registerRoute( 43 /\.(?:png|gif|jpg|jpeg|webp|svg)(\?.*)?$/gim, 44 new workbox.strategies.CacheFirst({ 45 cacheName: 'diginomica-imgs', 46 plugins: [ 47 new workbox.cacheableResponse.CacheableResponsePlugin({ 48 statuses: [200], 49 }), 50 ], 51 }), 52 'GET', 53); 54 55workbox.routing.registerRoute( 56 /\.(?:css|js)(\?.*)?$/gim, 57 new workbox.strategies.StaleWhileRevalidate({ 58 cacheName: 'diginomica-assets', 59 plugins: [ 60 new workbox.cacheableResponse.CacheableResponsePlugin({ 61 statuses: [200], 62 }), 63 ], 64 }), 65 'GET', 66); 67 68workbox.routing.registerRoute( 69 /(\/admin|\/user)/gim, 70 new workbox.strategies.NetworkOnly({ 71 cacheName: 'diginomica-admin', 72 }), 73 'GET', 74); 75 76workbox.routing.setDefaultHandler( 77 new workbox.strategies.NetworkFirst({ 78 plugins: [ 79 new workbox.cacheableResponse.CacheableResponsePlugin({ 80 statuses: [200], 81 }), 82 ], 83 }), 84); 85 86workbox.routing.setCatchHandler(({ event }) => { 87 switch (event.request.destination) { 88 case 'document': 89 return caches.match(FALLBACK_URL); 90 91 case 'image': 92 return caches.match(FALLBACK_IMG); 93 94 default: 95 return Response.error(); 96 } 97}); 98 99workbox.googleAnalytics.initialize({ 100 parameterOverrides: { 101 cd1: 'offline', 102 }, 103});
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.