-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathsw.js
94 lines (85 loc) · 2.81 KB
/
sw.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// TODO: Update the sw implementation to save on cache only the fonts,Google Analitics, Api (World Status) response and the languages
// import { registerRoute, NavigationRoute } from 'workbox-routing';
// import { NetworkFirst, CacheFirst, StaleWhileRevalidate } from 'workbox-strategies';
// import { precacheAndRoute } from 'workbox-precaching';
// import { CacheableResponsePlugin } from 'workbox-cacheable-response';
// import { ExpirationPlugin } from 'workbox-expiration';
// import { createHandlerBoundToURL } from 'workbox-precaching';
// /* Install new SW when user clicks 'Update app' */
// self.addEventListener('message', (event) => {
// if (event.data && event.data.type === 'SKIP_WAITING') {
// self.skipWaiting();
// }
// });
// /* Cache the Google Fonts stylesheets with a stale-while-revalidate strategy. */
// registerRoute(
// /^https:\/\/fonts\.googleapis\.com/,
// new StaleWhileRevalidate({
// cacheName: 'google-fonts-stylesheets',
// })
// );
// /* Cache the underlying font files with a cache-first strategy for 1 year. */
// registerRoute(
// /^https:\/\/fonts\.gstatic\.com/,
// new CacheFirst({
// cacheName: 'google-fonts-webfonts',
// plugins: [
// new CacheableResponsePlugin({
// statuses: [0, 200],
// }),
// new ExpirationPlugin({
// maxAgeSeconds: 60 * 60 * 24 * 365,
// maxEntries: 30,
// }),
// ],
// })
// );
// /**
// * Runtime country json data files with a network-first strategy, we want up to date data,
// * but in the case of no connection, return cached data
// */
// registerRoute(
// new RegExp('.*data/territories/.*.json'),
// new NetworkFirst({
// cacheName: 'territories',
// plugins: [
// new ExpirationPlugin({
// maxEntries: 5,
// purgeOnQuotaError: true
// }),
// ],
// })
// );
// /**
// * Runtime json data files with a network-first strategy, we want up to date data,
// * but in the case of no connection, return cached data
// */
// registerRoute(
// new RegExp('.*data/.*.json'),
// new NetworkFirst({
// cacheName: 'datafiles'
// })
// );
// /**
// * Corona tracker, network first
// * This can start hogging up storage if users click on a lot of
// * countries, so we restrict to 20 max
// */
// registerRoute(
// new RegExp('https://api.coronatracker.com/v3/.*'),
// new NetworkFirst({
// cacheName: 'coronatracker',
// plugins: [
// new ExpirationPlugin({
// maxEntries: 5,
// purgeOnQuotaError: true
// }),
// ],
// })
// );
// /* Precache manifest */
// precacheAndRoute(self.__WB_MANIFEST);
// /* Return index.html on navigations */
// const handler = createHandlerBoundToURL('/index.html');
// const navigationRoute = new NavigationRoute(handler, {});
// registerRoute(navigationRoute);