Skip to content

Commit a1b9776

Browse files
committed
Attempt to purge the old site with a self-destructing service worker
1 parent 4c95fdc commit a1b9776

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

public/sw.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// cleanup old Gatsby ServiceWorkers
2+
// https://github.com/NekR/self-destroying-sw
3+
self.addEventListener('install', function (e) {
4+
self.skipWaiting();
5+
});
6+
7+
self.addEventListener('activate', function (e) {
8+
self.registration
9+
.unregister()
10+
.then(function () {
11+
return self.clients.matchAll();
12+
})
13+
.then(function (clients) {
14+
clients.forEach((client) => client.navigate(client.url));
15+
});
16+
});

0 commit comments

Comments
 (0)