setto.basspistol.com/service-worker.js

41 lines
993 B
JavaScript
Raw Normal View History

2020-08-05 16:56:35 +02:00
// 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
workbox.routing.registerRoute(
/assets\/(img|icons|css)/,
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()
);