Skip to content

Commit 0a183a1

Browse files
committed
Force-unregister SW
1 parent 144216b commit 0a183a1

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

_layouts/default.html

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,20 @@
7575

7676
<script>
7777
if ('serviceWorker' in navigator) {
78-
window.addEventListener('load', function() {
79-
navigator.serviceWorker.register('/sw.js?0166').then(function(registration) {
80-
// Successfully registered the Service Worker
81-
//console.log('Service Worker registration successful with scope: ', registration.scope);
82-
}).catch(function(err) {
83-
// Failed to register the Service Worker
84-
//console.log('Service Worker registration failed: ', err);
85-
});
86-
});
78+
79+
navigator.serviceWorker.getRegistrations()
80+
.then(registrations => {
81+
return Promise.all(
82+
registrations.map(reg => reg.unregister())
83+
);
84+
})
85+
86+
.then(() => caches.keys())
87+
.then(names => {
88+
return Promise.all(
89+
names.map(name => caches.delete(name))
90+
);
91+
})
92+
8793
}
8894
</script>

0 commit comments

Comments
 (0)