Skip to content

Commit

Permalink
Reset cache name version, #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Elhamne committed Feb 27, 2023
1 parent bfa197c commit ff84aee
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions public/sw.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable array-callback-return */
/* eslint-disable no-undef */
const staticCacheName = 'SAY-v2.0.3-beta';
const dynamicCacheName = 'SAY-dynamic-v5';
const staticCacheName = 'SAY-v2.0.1-beta';
const dynamicCacheName = 'SAY-dynamic-v1';
const urlsToCache = [
'/',
'/index.html',
Expand Down Expand Up @@ -54,7 +54,6 @@ const limitCacheSize = async (name, size) => {

// Install service worker
self.addEventListener('install', (e) => {
// console.log('service worker installed');
e.waitUntil(
(async () => {
const cache = await caches.open(staticCacheName);
Expand All @@ -65,12 +64,12 @@ self.addEventListener('install', (e) => {

// activate event - deleting old caches
self.addEventListener('activate', (e) => {
// console.log('service worker has been activated');
const cacheKeepList = [staticCacheName, dynamicCacheName];
e.waitUntil(
caches.keys().then((keyList) => {
return Promise.all(
keyList
.filter((key) => key !== staticCacheName && key !== dynamicCacheName)
.filter((key) => !cacheKeepList.includes(key))
.map((key) => caches.delete(key))
);
})
Expand Down

0 comments on commit ff84aee

Please sign in to comment.