Important Note and link to whole Project:
You can also use PROMISES in your activation events.Using promises while deleting the cache is more effective.Here is the same code using promises to delete old cache during the activation:
Source code:
PS:Mind the equals to and arrow sign.You know where to change :)
self.addEventListener('activate',event={ //change equalto with arrow
event.waitUntil(
caches.keys() //provide the name of all caches
.then(cacheNames={ //change equal to with arrow
return Promise.all(
cacheNames.map(cache={ //change equal to with arrow
if(cache != ourcachename){
console.info("Deleting old cache",cache)
return caches.delete(cache);
}
})
)
})
)
return self.clients.claim();
});
Link to whole project:
https://github.com/vivekneupane11/Pro...