-
Notifications
You must be signed in to change notification settings - Fork 21
/
service-worker.js
70 lines (64 loc) · 1.76 KB
/
service-worker.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
// /* eslint-disable no-undef */
// importScripts(
// 'https://storage.googleapis.com/workbox-cdn/releases/3.2.0/workbox-sw.js'
// )
// const CACHE_NAME = 'phpidjkt-pwa-20210126'
// workbox.precaching.precacheAndRoute([
// {
// url: '/index.html',
// revision: '20210126'
// },
// {
// url: '/assets/js/offcanvas.js',
// revision: '20210126'
// },
// {
// url: '/assets/js/slider.js',
// revision: '20210126'
// },
// {
// url: '/assets/js/header.js',
// revision: '20210126'
// },
// {
// url: '/assets/images/phpid-jakarta.png',
// revision: '20210126'
// }
// ])
// function generateCacheableConfig (name, maxEntry, maxDay) {
// return {
// cacheName: CACHE_NAME + name,
// plugins: [
// new workbox.cacheableResponse.Plugin({
// statuses: [0, 200]
// }),
// new workbox.expiration.Plugin({
// maxEntries: maxEntry,
// maxAgeSeconds: maxDay * 24 * 60 * 60
// })
// ]
// }
// }
// workbox.routing.registerRoute(/\.(?:png|gif|jpg|jpeg|svg|js|css)$/,
// workbox.strategies.cacheFirst(generateCacheableConfig('__staticResources', 50, 30)),
// );
// const thirdPartyRoutes = [
// {
// regexes: [
// '^https://fonts.(?:googleapis|gstatic).com/(.*)',
// '^https://storage.(?:googleapis|gstatic).com/(.*)',
// '^https://cdnjs.cloudflare.com/(.*)',
// '^https://code.ionicframework.com/(.*)',
// '^https://c.disquscdn.com/(.*)'
// ],
// cache: generateCacheableConfig('__thirdparty', 20, 7)
// }
// ]
// thirdPartyRoutes.map(function (item) {
// item.regexes.map(function (regStr) {
// workbox.routing.registerRoute(
// new RegExp(regStr),
// workbox.strategies.cacheFirst(item.cache)
// )
// })
// })