1/** 2 * Welcome to your Workbox-powered service worker! 3 * 4 * You'll need to register this file in your web app and you should 5 * disable HTTP caching for this file too. 6 * See https://goo.gl/nhQhGp 7 * 8 * The rest of the code is auto-generated. Please don't update this file 9 * directly; instead, make changes to your Workbox build configuration 10 * and re-run your build process. 11 * See https://goo.gl/2aRDsh 12 */ 13 14importScripts("workbox-v4.3.1/workbox-sw.js"); 15workbox.setConfig({modulePathPrefix: "workbox-v4.3.1"}); 16 17workbox.core.setCacheNameDetails({prefix: "gatsby-plugin-offline"}); 18 19workbox.core.skipWaiting(); 20 21workbox.core.clientsClaim(); 22 23/** 24 * The workboxSW.precacheAndRoute() method efficiently caches and responds to 25 * requests for URLs in the manifest. 26 * See https://goo.gl/S9QRab 27 */ 28self.__precacheManifest = [ 29 { 30 "url": "webpack-runtime-0b577f06ca840895f82f.js" 31 }, 32 { 33 "url": "styles.6307a49f7d669b76e4dc.css" 34 }, 35 { 36 "url": "styles-74f186b97326e2ede606.js" 37 }, 38 { 39 "url": "framework-7a18812a6c0aed44bf88.js" 40 }, 41 { 42 "url": "app-780b4a6b1218020b3bb1.js" 43 }, 44 { 45 "url": "offline-plugin-app-shell-fallback/index.html", 46 "revision": "398ab39ffbd46861c05cd7527bc4c194" 47 }, 48 { 49 "url": "component---cache-caches-gatsby-plugin-offline-app-shell-js-2e0ffbfd0c4f89e2babf.js" 50 }, 51 { 52 "url": "polyfill-1861bf3ce626d9e9856f.js" 53 }, 54 { 55 "url": "manifest.webmanifest", 56 "revision": "3b22e4a2139a1f26bf2e08f393a7bd75" 57 } 58].concat(self.__precacheManifest || []); 59workbox.precaching.precacheAndRoute(self.__precacheManifest, {}); 60 61workbox.routing.registerRoute(/(\.js$|\.css$|static\/)/, new workbox.strategies.CacheFirst(), 'GET'); 62workbox.routing.registerRoute(/^https?:.*\/page-data\/.*\.json/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 63workbox.routing.registerRoute(/^https?:.*\.(png|jpg|jpeg|webp|svg|gif|tiff|js|woff|woff2|json|css)$/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 64workbox.routing.registerRoute(/^https?:\/\/fonts\.googleapis\.com\/css/, new workbox.strategies.StaleWhileRevalidate(), 'GET'); 65 66/* global importScripts, workbox, idbKeyval */ 67importScripts(`idb-keyval-3.2.0-iife.min.js`) 68 69const { NavigationRoute } = workbox.routing 70 71let lastNavigationRequest = null 72let offlineShellEnabled = true 73 74// prefer standard object syntax to support more browsers 75const MessageAPI = { 76 setPathResources: (event, { path, resources }) => { 77 event.waitUntil(idbKeyval.set(`resources:${path}`, resources)) 78 }, 79 80 clearPathResources: event => { 81 event.waitUntil(idbKeyval.clear()) 82 }, 83 84 enableOfflineShell: () => { 85 offlineShellEnabled = true 86 }, 87 88 disableOfflineShell: () => { 89 offlineShellEnabled = false 90 }, 91} 92 93self.addEventListener(`message`, event => { 94 const { gatsbyApi: api } = event.data 95 if (api) MessageAPI[api](event, event.data) 96}) 97 98function handleAPIRequest({ event }) { 99 const { pathname } = new URL(event.request.url) 100 101 const params = pathname.match(/:(.+)/)[1] 102 const data = {} 103 104 if (params.includes(`=`)) { 105 params.split(`&`).forEach(param => { 106 const [key, val] = param.split(`=`) 107 data[key] = val 108 }) 109 } else { 110 data.api = params 111 } 112 113 if (MessageAPI[data.api] !== undefined) { 114 MessageAPI[data.api]() 115 } 116 117 if (!data.redirect) { 118 return new Response() 119 } 120 121 return new Response(null, { 122 status: 302, 123 headers: { 124 Location: lastNavigationRequest, 125 }, 126 }) 127} 128 129const navigationRoute = new NavigationRoute(async ({ event }) => { 130 // handle API requests separately to normal navigation requests, so do this 131 // check first 132 if (event.request.url.match(/\/.gatsby-plugin-offline:.+/)) { 133 return handleAPIRequest({ event }) 134 } 135 136 if (!offlineShellEnabled) { 137 return await fetch(event.request) 138 } 139 140 lastNavigationRequest = event.request.url 141 142 let { pathname } = new URL(event.request.url) 143 pathname = pathname.replace(new RegExp(`^`), ``) 144 145 // Check for resources + the app bundle 146 // The latter may not exist if the SW is updating to a new version 147 const resources = await idbKeyval.get(`resources:${pathname}`) 148 if (!resources || !(await caches.match(`/app-780b4a6b1218020b3bb1.js`))) { 149 return await fetch(event.request) 150 } 151 152 for (const resource of resources) { 153 // As soon as we detect a failed resource, fetch the entire page from 154 // network - that way we won't risk being in an inconsistent state with 155 // some parts of the page failing. 156 if (!(await caches.match(resource))) { 157 return await fetch(event.request) 158 } 159 } 160 161 const offlineShell = `/offline-plugin-app-shell-fallback/index.html` 162 const offlineShellWithKey = workbox.precaching.getCacheKeyForURL(offlineShell) 163 return await caches.match(offlineShellWithKey) 164}) 165 166workbox.routing.registerRoute(navigationRoute) 167 168// this route is used when performing a non-navigation request (e.g. fetch) 169workbox.routing.registerRoute(/\/.gatsby-plugin-offline:.+/, handleAPIRequest)
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.