Compare commits
2 commits
main
...
servicewor
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3052faddb5 | ||
![]() |
65f95dc33c |
1 changed files with 7 additions and 2 deletions
|
@ -55,9 +55,14 @@ async function doRegister() {
|
|||
// f.e on first access.
|
||||
registration.addEventListener("updatefound", () => {
|
||||
console.log("Reloading the page to transfer control to the Service Worker.");
|
||||
window.location.reload();
|
||||
try {
|
||||
window.location.reload();
|
||||
} catch (err) {
|
||||
console.log("Service Worker failed reloading the page. ERROR:" + err);
|
||||
};
|
||||
});
|
||||
// If the registration is active, but it's not controlling the page, reload the page to have it take control
|
||||
// When the registration is active, but it's not controlling the page, we reload the page to have it take control.
|
||||
// This f.e occurs when you hard-reload (shift + refresh). https://www.w3.org/TR/service-workers/#navigator-service-worker-controller
|
||||
if (registration.active && !navigator.serviceWorker.controller) {
|
||||
console.log("Reloading the page to transfer control to the Service Worker.");
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue