WICG/priority-hints

add use case for service worker resource installation

wanderview opened this issue · 3 comments

Another use case for priority hints I've heard recently is to de-prioritize fetch() and cache.addAll() calls in a service worker install event. This could help avoid the background installation of many resources from starving out any requests initiated from the active window on the main thread.

Just FYI in case this is worth including in the list of use cases in the spec.

Thanks for filing this issue; I was just about to do that. :)

I opened an issue on Firefox before realizing that there is no guarantee that resources requested during the Service Worker install phase (e.g. caches.addAll()) are lower-priority than requests made on the main thread. So it looks like ideally we would want priority hints for cache[s].add[All] as well.

cache.addAll() takes Request objects, so it should accept the importance attribute just like fetch.

There are now specs and examples for how it is exposed on the Request object and used with fetch(). It will work with cache[s].add[All] as well but there aren't any explicit examples of that.