-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
consider exposing and allowing script to set Request priority #436
Comments
@wanderview How does that IDL sketch reconcile with https://fetch.spec.whatwg.org/#fetching ? That is, that 'priority' is a user-agent defined object, but the IDL sketch seems to make it a specific set of values (no longer UA defined) In particular, I'm thinking about the Note in Step 5
At least in Chrome, the low/normal/high is not a priority system we're happy with, and certainly not with exposing, at least historically speaking. Even weighting numeric priorities has caused a host of issues with H/2 processing, and we're trying to move away from that. I'm not sure how Firefox is handling that, but I thought @mcmanus had implemented a much more nuanced priority/dependency tracking already. |
You can read my post as "exact priority enum values TBD". I did indicate script specified priority would be a hint and not a guarantee. I think this value could reflect intent, but not necessarily exact implementation detail. I would not want this API to constrain the implementation. |
the priority low->high paradigm is certainly better than nothing.. at some point when combining different classes of things (or things from different sources - but that's outside the scope of one script) it devolves into needing dependencies.. but that's a lot of complexity and a lot of complexity authors prefer to avoid and honestly screw up. As long as you're not combining things from multiple sources (i.e. things that aren't aware of each other or trust each other) you can mostly get by with priorities. Especially if you can reprioritize. I'm not sure what the right balance in this API is but I lean towards at least some sense of classification if you don't feel full on deps are appropriate. firefox does do a lot of dependency management for markup, but when it comes to scripts it has little idea what is going on.. and as mentioned before without some kind of classification or dependency system combining these scopes is super hard. |
I'd be happy with just "low" and "default" or something. The "low" value is to indicate something explicitly de-prioritized like a beacon, etc. |
I think that a priority indication, both for A few use-cases:
All these cases require a priority downgrade. I'm not sure if there are other cases that require an upgrade. |
cc @domfarolino |
Thanks for the cc! Since this thread's birth, this idea has been embodied in Priority Hints, and is currently being discussed at whatwg/html#3670 to see if we can get it in HTML/Fetch. @wanderview we're currently going with I know that priority as request concept already exists here, but how do we feel about having another concept
|
Sorry, I missed #436 (comment) when it was first written. It does feel a bit confusing to have both Maybe since |
Also, if Priority Hints exposes an |
Good points. We do have some discussion around that right now, but ultimately it seems reasonable to expose it. Main thing we're worried about now is a hint's effects taking place twice. For example, the UA defers sending If welcomed, I can start working on HTML and Fetch Standard PRs for this. HTML Standard issue is filed here (whatwg/html#3670) for reference. |
AFAICT this isn't really permitted by the spec today. The fetching algorithm does not have any variation in how Handle Fetch is invoked. I think this kind of observable change would have to be discussed as a separate issue. Also, I highly doubt prioritization before the service worker would be worth the complexity. Unless the service worker is doing blocking operations, like spinning a loop on js-level computations, then there should be very little request queueing in front of the service worker. The one exception is when you need to spawn the service worker, but in that case I don't see how prioritization is going to make anything faster. |
What's the status here? I was thinking there might also be some overlap with #184 in that low-priority requests could potentially be coalesced. |
I believe @natechapin is working on this problem from the Chrome side now. I'll let him expand, but I think the latest thinking after priority hints didn't show promise is to allow applications to manipulate fetch priority using similar tools to how they manipulate JS task priority, with the hopes that this allows applications to make more holistic decisions like "this whole section of code, including its fetches, is less important". The connection to #184 and coalescing is very interesting and I'd be interested in his take there. |
Currently the browser makes a number of decisions about what network requests are high priority vs low priority. We could expose this as a
Request.priority
attribute.In addition, we could allow script to set this so that authors can hint that some requests are low priority. For example, think of a
requestIdleCallback()
that is intended to avoid interfering with normal page operation, but it needs a network request. It could use a "low" priority.Another use case would be pre-caching resources at a low priority in a ServiceWorker's install event handler. This would reduce any impact to the currently displayed page.
I don't think we would want to guarantee honoring the value, though. It would be a hint and best effort by the browser.
Webidl sketch:
Service workers would also be able to inspect priority:
The text was updated successfully, but these errors were encountered: