-
Notifications
You must be signed in to change notification settings - Fork 8
/
sw.js
32 lines (31 loc) · 792 Bytes
/
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
// cache these items
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open('blog-tracker').then(function(cache) {
return cache.addAll([
'/',
'index.html',
'writer.html',
'css/normalize-7.0.0.css',
'css/style.css',
'js/project-manager.js',
'js/jquery-3.2.1.js',
'js/pouchdb-6.3.4.js',
'js/credentials.js',
'manifest.json',
'images/logo-450x450.png'
]);
})
.catch((e) => {
// failing first time?
})
);
});
// load from cache first, then network if available
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});