self.addEventListener('activate', event => {
// delete any caches that aren't in expectedCaches
event.waitUntil(
caches.keys().then(keys => Promise.all(
keys.map(key => {
if (!expectedCaches.includes(key)) {
return caches.delete(key);
}
})
)).then(() => {
self.clients.claim();
console.log('myCache-v1 now ready to handle fetches!');
})
);
});
I want to minimize the cache update time. Instead of deleting the entire cache and replace. I want to update only changed files.
Problem I faced: User is not online so long time. It will check and update full cache then it replace.