-
Notifications
You must be signed in to change notification settings - Fork 310
/
Copy pathserviceWorker.js
144 lines (130 loc) · 3.5 KB
/
serviceWorker.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* global workbox */
/* eslint-disable no-restricted-globals */
// Uncomment the following line if you don't want to see Workbox log lines while debugging
workbox.setConfig({ debug: false });
// Note: The self.__precacheManifest variable will be imported from a file that will be dynamically generated by workbox.
// workbox.precaching.precacheAndRoute(self.__precacheManifest);
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST);
workbox.routing.registerRoute(
/https:\/\/api.wevoteusa.org\/apis/,
new workbox.strategies.NetworkFirst({
cacheName: 'weVoteApiCache',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 100,
maxAgeSeconds: 10 * 24 * 60 * 60, // 10 Days
}),
],
}),
);
workbox.routing.registerRoute(
/https:\/\/cdn.wevoteusa.org\/apis/,
new workbox.strategies.CacheFirst({
cacheName: 'weVoteApiCache',
}),
);
workbox.routing.registerRoute(
/https:\/\/maps\.googleapis\.com/,
new workbox.strategies.CacheFirst({
cacheName: 'weVoteGoogleCache',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 10,
maxAgeSeconds: 10 * 24 * 60 * 60, // 10 Days
}),
],
}),
);
workbox.routing.registerRoute(
/https:\/\/fonts\.gstatic\.com/,
new workbox.strategies.CacheFirst({
cacheName: 'weVoteGoogleCache',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 30,
maxAgeSeconds: 10 * 24 * 60 * 60, // 10 Days
}),
],
}),
);
workbox.routing.registerRoute(
/https:\/\/wevote-images\.s3\.amazonaws\.com/,
new workbox.strategies.CacheFirst({
cacheName: 'weVoteImageCache',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 60,
maxAgeSeconds: 10 * 24 * 60 * 60, // 10 Days
}),
],
}),
);
// Don't care about zen when offline, but it makes subsequent online loads faster
workbox.routing.registerRoute(
/https:\/\/ekr\.zdassets\.com/,
new workbox.strategies.CacheFirst({
cacheName: 'weVoteZenCache',
}),
);
workbox.routing.registerRoute(
/https:\/\/static\.zdassets\.com/,
new workbox.strategies.CacheFirst({
cacheName: 'weVoteZenCache',
}),
);
workbox.routing.registerRoute(
/https:\/\/cdnjs\.cloudflare\.com/,
new workbox.strategies.CacheFirst({
cacheName: 'weVoteCloudFlareCache',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 30,
maxAgeSeconds: 10 * 24 * 60 * 60, // 10 Days
}),
],
}),
);
// workbox.routing.registerRoute(
// /https:\/\/use\.fontawesome\.com/,
// new workbox.strategies.CacheFirst({
// cacheName: 'weVoteCloudFlareCache',
// }),
// );
workbox.routing.registerRoute(
/https:\/\/connect\.facebook\.net/,
new workbox.strategies.CacheFirst({
cacheName: 'weVoteFacebookCache',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 30,
maxAgeSeconds: 10 * 24 * 60 * 60, // 10 Days
}),
],
}),
);
workbox.routing.registerRoute(
/https:\/\/m\.stripe\.network/,
new workbox.strategies.CacheFirst({
cacheName: 'weVoteStripeCache',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 30,
maxAgeSeconds: 10 * 24 * 60 * 60, // 10 Days
}),
],
}),
);
// workbox.routing.registerRoute(
// /\.*?svg$/,
// new workbox.strategies.CacheFirst({
// cacheName: 'WeVoteSVGCache',
// // plugins: [
// // new workbox.expiration.Plugin({
// // maxEntries: 60,
// // maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
// // }),
// // ],
// }),
// );
//
//