Skip to content

Commit 9a2e7c0

Browse files
authored
chore(docs): add SW to clear cached data in vuepress/pwa (#124)
1 parent 3c08550 commit 9a2e7c0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"use strict"
2+
3+
// https://github.com/NekR/self-destroying-sw
4+
/* globals self */
5+
self.addEventListener("install", () => {
6+
self.skipWaiting()
7+
})
8+
9+
self.addEventListener("activate", () => {
10+
self.registration
11+
.unregister()
12+
.then(() => self.clients.matchAll())
13+
.then((clients) => {
14+
for (const client of clients) {
15+
client.navigate(client.url)
16+
}
17+
})
18+
})

0 commit comments

Comments
 (0)