Fix problem of multiple service workers being registered

Source:
https://stackoverflow.com/questions/33816342/how-to-prevent-the-same-service-worker-from-registering-over-multiple-pages
This commit is contained in:
André Setti
2019-02-08 02:20:26 -02:00
committed by GitHub
parent 2326895768
commit ab8db72bd3

View File

@@ -36,7 +36,7 @@
// Initialize the service worker // Initialize the service worker
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/serviceworker.js', { navigator.serviceWorker.register('/serviceworker.js', {
scope: '.' scope: '/'
}).then(function (registration) { }).then(function (registration) {
// Registration was successful // Registration was successful
console.log('django-pwa: ServiceWorker registration successful with scope: ', registration.scope); console.log('django-pwa: ServiceWorker registration successful with scope: ', registration.scope);