Skip to content

Commit 9a8f1da

Browse files
Update service worker for PWA
1 parent 482aa98 commit 9a8f1da

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

public/sw.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const urlsToCache = [
66
'/favicon.ico'
77
];
88

9-
// Install event - cache static assets
109
self.addEventListener('install', (event) => {
10+
// skip waiting to activate new SW immediately and cache static assets
1111
event.waitUntil(
1212
caches.open(STATIC_CACHE)
1313
.then((cache) => {
@@ -19,8 +19,8 @@ self.addEventListener('install', (event) => {
1919
);
2020
});
2121

22-
// Activate event - clean up old caches
2322
self.addEventListener('activate', (event) => {
23+
// immediately take control of all pages and clean up old caches
2424
event.waitUntil(
2525
caches.keys().then((cacheNames) => {
2626
return Promise.all(

0 commit comments

Comments
 (0)