WICG / priority-hints

A browser API to enable developers signal the priorities of the resources they need to download.
https://wicg.github.io/priority-hints/
Other
271 stars 26 forks source link

add use case for service worker resource installation #40

Closed wanderview closed 2 years ago

wanderview commented 5 years ago

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.

nolanlawson commented 5 years ago

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.

wanderview commented 5 years ago

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

pmeenan commented 2 years ago

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.