Provider Workers: an Introduction. What exactly is an ongoing solution worker
One typical task that will take place in the activate callback is cache management. The main reason it is in addition crucial to repeat this within the callback that is activate because if perhaps you were to get rid of any old caches within the install action, any old solution worker, which will keep control over all of the present pages, will instantly stop having the ability to provide files from that cache.
Suppose we now have one cache called ‘my-site-cache-v1’ , and we also realize that we should separate this out into one cache for pages and something cache for websites. What this means is within the step that is install’d produce two caches, ‘pages-cache-v1’ and ‘blog-posts-cache-v1’ as well as in the activate action we’d would you like to delete our older ‘my-site-cache-v1’ .
The following rule would do that by looping through every one of the caches into the service worker and deleting any caches that are not defined within the cache allowlist.
Rough edges and gotchas
These items is truly new. Here is an accumulation conditions that block the way. Ideally this part could be deleted quickly, but also for now they are well well worth mindful that is being of.
If installation fails, we are not great at suggesting about any of it