-
Notifications
You must be signed in to change notification settings - Fork 28
Support SW install usage case via new property on Request interface #11
Comments
I agree with that approach, currently something very similar to what you suggest is what I proposed in Chromium's design doc, if that interests you at all. |
@jeffposnick If you get a chance, would you mind taking a look at the draft section proposed in the design doc? We've published the intent to implement PR today and hope to follow up with issues/PRs against both the Fetch spec and HTML standard as time goes on. Just want to sanity check we're addressing the use-case you had sufficiently :) |
The writeup in https://docs.google.com/document/d/1JutABSrbPEWMLW0ZXtySdd-4OOisf4Rbc00T_hHFc3U/edit?ts=5aa8b197#heading=h.9u6yqf4j5iy3 looks great to me, @domfarolino! Excited to see this move forward. |
Circling back on this issue to discuss a little more about potentially exposing the
@yutakahirano was initially a proponent of not exposing
...are there some good use-cases for exposing this property that ServiceWorker app code might be able to take advantage of? Happy to continue this discussion elsewhere, perhaps in another issue, but it seems worth bringing up in general. |
Apologies, but I'm not very familiar with some of the terminology common in specifications or the internal implementation of objects within browsers. I am not 100% clear on what
means. I think you're saying that If my interpretation is correct, then sure, I think that would be sufficient to take care of the use case I had in mind—I care about being able to set it at creation, rather than reading the value from an arbitrary |
Sorry for the lack of clarity! Yeah, basically |
Thanks! I could imagine a service worker's Being able to inspect that field post-construction is not high on the list of things I would consider important. |
I think it should probably be exposed on Request for a few reasons:
|
I am also in favor of exposing Request.importance. I think consistency is a big thing and agree with that point; regarding (2), that's interesting, I knew you could use a |
So my thinking on this topic probably just echoes what has been expressed already here or on related issues. Since priority hints, namely the To capture my thoughts from Twitter:
|
Thanks @LPardue for weighing in and sharing your use-case, quite interesting! I think these are really good points you bring up, and definitely strong arguments in favor of exposing |
From the W3C TAG review request, there is a concern that the current explainer doesn't demonstrate how to use It'd be great for to see these expanded examples included in the Explainer as well. On a related point, will the |
This is a great point, and reminds me of something I've been meaning to ask regarding the Explainer doc. As the spec matures, and becomes more fleshed out and well-shaped, are we to maintain the Explainer doc at equal pace, or does it eventually get "deprecated" in favor of the spec? Apologies if this is a rookie question...it seems that they are essentially overlapping as the spec matures though, no?
If we s/priority/importance, then the answer is yes. In Chrome's flagged implementation of this right now, |
@wanderview The spec has it added as a property of Request and I'm working on plumbing it through Chrome, but to set expectations:
By the time a request makes it to the service worker (in Chrome), it has already been prioritized and there is an internal "priority" that is carried through. I believe it is copied through when you clone a request but I should verify.
There's a bit of risk here that developers should probably be aware of. Multiple requests for the same resource get de-duplicated so the worker will only see the details of the first request but if a later request is for a higher priority, it will be reprioritized internally but there are no callbacks to the worker to let it know of priority changes or the context of multiple requests de-duped to the same fetch. There's a risk of thinking a request is low priority in a worker since that's all it would see on the hint even if a high-priority request was also linked to it. It's a bit of an edge case but something to be careful of before getting too fancy (like lazy-loading it or requesting a low-resolution version or something). |
This falls into the buckets of things that are probably going to be covered by virtue of the existing placeholders for the Fetch API usage examples, but I wanted to make sure that whatever solutions are proposed end up taking a specific use case into account: control over priority for requests used to populate caches inside of a service worker's
install
handler.The most common way of doing that is not to use the Fetch API directly, but instead to use the Cache Storage API's
add()
oraddAll()
methods. Those methods can take inRequest
objects as parameters, in the same way that the Fetch API can.So it would be preferable if the mechanism for indicating priority where associated with the
Request
interface, and another something directly tied to the Fetch API'sfetch()
method. I'm not well-versed in the language of specifications, but it seems like extending https://fetch.spec.whatwg.org/#request to include:would be sufficient. The placeholder values would correspond to whatever strings are agreed upon in #7
I'm happy to file this against the Fetch API spec eventually, but it seems like that might be premature at this point.
The text was updated successfully, but these errors were encountered: