From 3fed18fc6cb5288a3823a1acb224e7b7929b8e52 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 14 Jul 2018 14:17:33 +0200 Subject: [PATCH] self destroying service worker * https://github.com/NekR/self-destroying-sw --- static/sw.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 static/sw.js diff --git a/static/sw.js b/static/sw.js new file mode 100644 index 0000000..216f7b5 --- /dev/null +++ b/static/sw.js @@ -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)) + }) +})