My website offers an array of web apps for each client. Each client has a different mix of apps that can be used.
Each web app is a hosted in a different folder.
I don't know, but the accepted answer didn't worked for me as it has typos as wells missing code I think. I am putting below what worked for me. Though I don't want to take away any credit from the accepted answer, but just adding a working code, which will help others.
self.addEventListener('activate', (event) => {
const cleanup = async () => {
const cacheNames = await caches.keys();// here it should be caches
console.log(cacheNames);
const cachesToDelete = cacheNames.filter(
(cacheNames) => (cacheNames.startsWith(`${registration.scope}!`) && cacheNames !== CACHE_NAME));
console.log(cachesToDelete);
// await Promise.all(cachesToDelete.map(caches.delete));// this line rewritten to make it working.
await Promise.all(cachesToDelete.map(CACHE_NAME=>{
return caches.delete(CACHE_NAME);
})
)
};
event.waitUntil(cleanup());
});