1importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.5.4/workbox-sw.js'); 2function escapeRegExp(string) { 3 return string.replace(/[.*+?^=!:()|[\]\/\\]/g, '\\$&'); 4} 5function targetHostRegExp() { 6 return '(' + escapeRegExp(location.origin) + '|' + escapeRegExp('https://yuhikaku.ismcdn.jp') + ')'; 7} 8function mwRegister() { 9 // console.log('register'); 10 var cacheId = 'mwcache'; 11 var mwResources = new RegExp('^' + targetHostRegExp() + '(?:/(common|resources)/.+)(?:\\?.*)?$'); 12 var mwImages = new RegExp('^' + targetHostRegExp() + '(?:/mwimgs/.+)(?:\\?.*)?$'); 13 workbox.core.setCacheNameDetails({prefix: cacheId}); 14 workbox.routing.registerRoute( 15 mwImages, 16 new workbox.strategies.CacheFirst({ 17 cacheName: cacheId + "-mwimages", 18 mode: 'no-cors', 19 plugins: [ 20 new workbox.cacheableResponse.CacheableResponsePlugin({ 21 statuses: [0, 200] 22 }), 23 new workbox.expiration.ExpirationPlugin({ 24 maxEntries: 255, 25 maxAgeSeconds: 7 * 24 * 60 * 60, 26 matchOptions: { 27 ignoreVary: true 28 }, 29 purgeOnQuotaError: true 30 }) 31 ] 32 }),'GET' 33 ); 34 workbox.routing.registerRoute( 35 mwResources, 36 new workbox.strategies.StaleWhileRevalidate({ 37 cacheName: cacheId + "-resources", 38 mode: 'no-cors', 39 plugins: [ 40 new workbox.cacheableResponse.CacheableResponsePlugin({ 41 statuses: [0, 200] 42 }), 43 new workbox.expiration.ExpirationPlugin({ 44 maxEntries: 255, 45 maxAgeSeconds: 7 * 24 * 60 * 60, 46 matchOptions: { 47 ignoreVary: true 48 }, 49 purgeOnQuotaError: true 50 }) 51 ] 52 }),'GET' 53 ); 54}; 55 56if (workbox) { 57 // console.log('workboxstart'); 58 workbox.setConfig({ debug: false }); 59 workbox.core.skipWaiting(); 60 workbox.core.clientsClaim(); 61 mwRegister(); 62} else { 63 // console.log('load error Workbox') 64} 65self.addEventListener('fetch', function(event) { 66 // console.log(event.request.url); 67}); 68
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.