|
1 |
| -// THIS FILE SHOULD NOT BE VERSION CONTROLLED |
| 1 | +importScripts('https://cdn.jsdelivr.net/npm/[email protected]/workbox/workbox-sw.js') |
2 | 2 |
|
3 |
| -// https://github.com/NekR/self-destroying-sw |
| 3 | +// -------------------------------------------------- |
| 4 | +// Configure |
| 5 | +// -------------------------------------------------- |
4 | 6 |
|
5 |
| -self.addEventListener('install', function (e) { |
6 |
| - self.skipWaiting() |
| 7 | +// Set workbox config |
| 8 | +workbox.setConfig({ |
| 9 | + "debug": false |
7 | 10 | })
|
8 | 11 |
|
9 |
| -self.addEventListener('activate', function (e) { |
10 |
| - self.registration.unregister() |
11 |
| - .then(function () { |
12 |
| - return self.clients.matchAll() |
13 |
| - }) |
14 |
| - .then(function (clients) { |
15 |
| - clients.forEach(client => client.navigate(client.url)) |
16 |
| - }) |
17 |
| -}) |
| 12 | +// Start controlling any existing clients as soon as it activates |
| 13 | +workbox.core.clientsClaim() |
| 14 | + |
| 15 | +// Skip over the SW waiting lifecycle stage |
| 16 | +workbox.core.skipWaiting() |
| 17 | + |
| 18 | +workbox.precaching.cleanupOutdatedCaches() |
| 19 | + |
| 20 | +// -------------------------------------------------- |
| 21 | +// Precaches |
| 22 | +// -------------------------------------------------- |
| 23 | + |
| 24 | +// Precache assets |
| 25 | + |
| 26 | +// -------------------------------------------------- |
| 27 | +// Runtime Caching |
| 28 | +// -------------------------------------------------- |
| 29 | + |
| 30 | +// Register route handlers for runtimeCaching |
| 31 | +workbox.routing.registerRoute(new RegExp('/vue-final-modal/_nuxt/'), new workbox.strategies.CacheFirst ({}), 'GET') |
| 32 | +workbox.routing.registerRoute(new RegExp('/vue-final-modal/'), new workbox.strategies.NetworkFirst ({}), 'GET') |
0 commit comments