에셋 리로드 서비스워커 해제
This commit is contained in:
@@ -155,6 +155,18 @@
|
||||
}).catch(function () {});
|
||||
}
|
||||
|
||||
function unregisterServiceWorkers() {
|
||||
if (!navigator.serviceWorker || !navigator.serviceWorker.getRegistrations) return Promise.resolve();
|
||||
|
||||
return navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||
return Promise.all(registrations.map(function (registration) {
|
||||
return registration.unregister().catch(function () {});
|
||||
}));
|
||||
}).catch(function () {});
|
||||
}
|
||||
|
||||
unregisterServiceWorkers();
|
||||
|
||||
function reloadWith(version) {
|
||||
var token = version.slice(0, 12);
|
||||
var marker = token + ':' + Math.floor(Date.now() / 10000);
|
||||
@@ -163,14 +175,7 @@
|
||||
if (assetTokenFromLocation() && sessionGet(reloadKey) === marker) return;
|
||||
|
||||
sessionSet(reloadKey, marker);
|
||||
withTimeout(deleteCaches(), 2500).then(function () {
|
||||
if (navigator.serviceWorker && navigator.serviceWorker.getRegistrations) {
|
||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||
registrations.forEach(function (registration) {
|
||||
if (registration && typeof registration.update === 'function') registration.update();
|
||||
});
|
||||
}).catch(function () {});
|
||||
}
|
||||
withTimeout(Promise.all([deleteCaches(), unregisterServiceWorkers()]), 2500).then(function () {
|
||||
window.location.replace(addQuery(window.location.href, 'assetReload', token));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user