1/* 2* Safari on iOS doesn't support registration.update() 3* https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/update 4* 5* So once you update this file then add a version number to the filename (-v2) and 6* unregister `service-workers.js` in the `register-service-worker.js` file. 7* 8* This is far from ideal but at least we know for sure that the service-worker is also 9* being updated in Safari on iOS. 10*/ 11importScripts( 12 '/service-workers/utils/get-video-from-cache-or-network.js', 13 '/service-workers/utils/claim-clients-and-remove-outdated-caches.js', 14 '/service-workers/utils/video-worker-utils.js', 15 '/service-workers/exponea/service-worker.min.js', 16) 17 18const VIDEO_CACHE_NAME = 'loavies-vimeo-cache-v1' 19 20/* 21* We only have to install the serviceworker because we don't have any 22* video's to precache. We only have a runtime cache, everything gets 23* fetched once and then put into the runtime cache. 24*/ 25self.addEventListener('install', () => { 26 if (self.skipWaiting) { 27 self.skipWaiting() 28 } 29}) 30 31/* 32* Remove outdated caches 33* https://developers.google.com/web/ilt/pwa/caching-files-with-service-worker#removing_outdated_caches 34*/ 35self.addEventListener('activate', event => { 36 event.waitUntil(claimClientsAndRemoveOutdatedCaches(VIDEO_CACHE_NAME)) 37}) 38 39/* 40* Serve segments from cache first if there are any. Otherwise, fetch 41* the resource from network and put it in the vimeo cache for the 42* next time the user visits our site. 43* 44* Only the requests to vimeo get intercepted, the rest will just be 45* treated as a regular network requests. 46*/ 47self.addEventListener('fetch', async event => { 48 if (isVideoRequest(event.request)) { 49 event.respondWith(getVideoFromCacheOrNetwork(event.request)) 50 } 51})
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.