Skip to content

Commit

Permalink
Speed up update process by skipping waiting and claiming currently op…
Browse files Browse the repository at this point in the history
…en pages -> no need to close all tabs in order to get an update anymore
  • Loading branch information
schlagmichdoch committed Feb 24, 2025
1 parent d18e290 commit dbd6321
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions public/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ const relativePathsNotToCache = [
]

self.addEventListener('install', function(event) {
// Perform install steps
// Perform install steps
console.log("Cache files for sw:", cacheVersion);
event.waitUntil(
caches.open(cacheTitle)
.then(function(cache) {
return cache
.addAll(relativePathsToCache)
.then(_ => {
console.log('All files cached.');
console.log('All files cached for sw:', cacheVersion);
self.skipWaiting();
});
})
);
Expand Down Expand Up @@ -182,6 +184,8 @@ self.addEventListener('fetch', function(event) {

// on activation, we clean up the previously registered service workers
self.addEventListener('activate', evt => {
console.log("Activate sw:", cacheVersion);
evt.waitUntil(clients.claim());
return evt.waitUntil(
caches
.keys()
Expand Down

0 comments on commit dbd6321

Please sign in to comment.