Workbox Routing / Caching / Deletion / Updation and service worker registration?

437 Views Asked by At

I have couple of questions regarding service worker and workbox.

1) When to register a service worker in webapp. * If I register directly in index.html, if I have precache assets then in first paint the precache assets are downloading twice once with request and once wit workbox which is delaying the first paint.

* If I register onload of page the issue is getting resolved but if I 
  have api hits which are to be cached it is getting cached on second 
  time refresh of the page.

2) In my webapp we use lot of 3rd party js,css,gif and soon. So in my routing if i want to cache them for each request if register a router it seems to be complex, so tried using regex patterns, So could any one suggest best regex to cache them if I need to exclude some image formats from caching. So the best way to cache third party js,css, api hits and so on other formats.

3) The best way to clear the cache, one is to use the expiration and all. But in my case if user changes his location I need to clear some cache contents, So how can I achieve this.

4) When to use caching and when to use indexeddb ?

5) Advantages of using workbox-webpack plugin then directly workbox. Any major advantages ?

6) Best practices for Registering/ unregistering/ updating service worker?

7) If I use workbox-webpack plugin and dynamic route to cache the js/css file so for every build changes a js/css file with different hash is being generated and its getting cached, So service worker caching the samefile with different hash values.

8) The best approach to forcefully delete a cache name and single file in cache.

0

There are 0 best solutions below