setto.basspistol.com/_service-worker.js
Set Hallstrom 0052959c5e remove PWA
2020-08-12 17:38:36 +02:00

41 lines
1,022 B
JavaScript

// service-worker.js
// set names for both precache & runtime cache
workbox.core.setCacheNameDetails({
prefix: 'SettoPWA',
suffix: 'v1',
precache: 'precache',
runtime: 'runtime-cache'
});
// let Service Worker take control of pages ASAP
workbox.skipWaiting();
workbox.clientsClaim();
// let Workbox handle our precache list
workbox.precaching.precacheAndRoute(self.__precacheManifest);
// use `networkFirst` strategy for `*.html`, like all my posts
workbox.routing.registerRoute(
/\.html$/,
workbox.strategies.networkFirst()
);
// use `cacheFirst` strategy for images and static assets
workbox.routing.registerRoute(
/assets\/(img|icons|fonts|webfonts)/,
workbox.strategies.cacheFirst()
);
workbox.routing.registerRoute(
/videos/,
workbox.strategies.cacheFirst()
);
workbox.routing.registerRoute(
/images\/(posts|pages)/,
workbox.strategies.cacheFirst()
);
// third party files
workbox.routing.registerRoute(
/^https?:\/\/media.basspistol.com/,
workbox.strategies.staleWhileRevalidate()
);