-
Notifications
You must be signed in to change notification settings - Fork 2
/
sw.js
42 lines (41 loc) · 1.17 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
const filesToCache = [
'/',
'/index.html',
'/manifest.json',
'/mini-dark.min.css',
'https://d33wubrfki0l68.cloudfront.net/css/1465af533389dc07c62369d47fe3e9f717222608/mini-dark.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.min.js',
'https://unpkg.com/[email protected]/dist/axios.min.js',
'/app.js',
'/app.min.js',
'/call-sw.js',
'/sw.js',
'/images/favicon-32x32.png',
'https://d33wubrfki0l68.cloudfront.net/f02bb05dcb421a0e82065b9bd8da8f298e5f1ac8/5fd2b/images/favicon-32x32.png',
'/images/android-icon-192x192.png',
'/images/logo.png'
]
self.addEventListener('install', function(event) {
self.skipWaiting()
event.waitUntil(
caches.open('v1.3').then(function(cache) {
return cache.addAll(filesToCache)
})
)
})
// Regular method, cache first:
// self.addEventListener('fetch', function(event) {
// event.respondWith(
// caches.match(event.request).then(function(response) {
// return response || fetch(event.request)
// })
// )
// })
// Network falling back to cache method:
self.addEventListener('fetch', function(event) {
event.respondWith(
fetch(event.request).catch(function() {
return caches.match(event.request);
})
);
});