1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-23 01:29:41 +01:00

self destroying service worker

* https://github.com/NekR/self-destroying-sw
This commit is contained in:
Matthias Kretschmann 2018-07-14 14:17:33 +02:00
parent ae25714987
commit 3fed18fc6c
Signed by: m
GPG Key ID: 606EEEF3C479A91F

14
static/sw.js Normal file
View File

@ -0,0 +1,14 @@
self.addEventListener('install', function() {
self.skipWaiting()
})
self.addEventListener('activate', function() {
self.registration
.unregister()
.then(function() {
return self.clients.matchAll()
})
.then(function(clients) {
clients.forEach(client => client.navigate(client.url))
})
})