-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsw.js
More file actions
19 lines (19 loc) · 723 Bytes
/
sw.js
File metadata and controls
19 lines (19 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var cacheName='phene.dev';
var filesToCache=['/','/index.html','/css/main.css',"/about","/about/index.html","/about/main.css","/privacy","/privacy/index.html"];
self.addEventListener('install',function(e){
console.log('[ServiceWorker] Install event detected');
e.waitUntil(caches.open(cacheName).then(function(cache){
console.log('[ServiceWorker] caching app shell');
return cache.addAll(filesToCache);
}))
});
self.addEventListener('activate',event=>{
event.waitUntil(self.clients.claim())
});
self.addEventListener('fetch',event=>{
event.respondWith(caches.match(event.request,{
ignoreSearch:true
}).then(Response=>{
return Response||fetch(event.request)
}))
})