forked from riccardoperra/codeimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.ts
More file actions
26 lines (19 loc) · 822 Bytes
/
sw.ts
File metadata and controls
26 lines (19 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import {clientsClaim} from 'workbox-core';
import {cleanupOutdatedCaches, precacheAndRoute} from 'workbox-precaching';
import {registerRoute} from 'workbox-routing';
import {StaleWhileRevalidate} from 'workbox-strategies';
declare let self: ServiceWorkerGlobalScope;
// self.__WB_MANIFEST is default injection point
precacheAndRoute(self.__WB_MANIFEST);
// Cache the Google Fonts stylesheets with a stale-while-revalidate strategy.
// clean old assets
cleanupOutdatedCaches();
// to allow work offline
// registerRoute(new NavigationRoute(createHandlerBoundToURL('index.html')));
registerRoute(({url}) => url.origin === '/assets/', new StaleWhileRevalidate());
registerRoute(
new RegExp('/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2)'),
new StaleWhileRevalidate(),
);
self.skipWaiting();
clientsClaim();