summaryrefslogtreecommitdiffstats
path: root/web_src/js/serviceworker.js
blob: e9dfde22f91401ef5a7989cadbfbd2c1a2252edc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import {registerRoute} from 'workbox-routing';
import {StaleWhileRevalidate} from 'workbox-strategies';

const cacheName = 'static-cache-v2';

const cachedDestinations = new Set([
  'manifest',
  'script',
  'style',
  'worker',
]);

registerRoute(
  ({request}) => cachedDestinations.has(request.destination),
  new StaleWhileRevalidate({cacheName}),
);