-
Notifications
You must be signed in to change notification settings - Fork 313
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
Where to put client / context #318
Comments
As far as I know, they're only useful on
|
Well, @mikewest and I discussed setting headers and some other things based on the |
Ohh, which headers are those? If it's for things like "Accept", I'd rather they were set on request construction such as: new Request('img.webp', {type: 'image'}); or Request.image('img.webp', opts); |
Well, |
I'd like to have See also #210 |
@slightlyoff |
|
Well |
|
How would the priority change? Having said that, there might be things you lose when you store it in the cache, but not sure if context is alone in that. |
Removing "impacts MVP" as client and context are out of scope for the MVP. |
Adding MVP, as it's blocking an MVP feature. See #497 |
#502 suggests putting this on Request makes more sense so it can be reused by |
There's a few things that the UA can do if we know how a response will be used. Some of which has been discussed here, and some which hasn't. Network prioritizationFirst of all we can make better default network prioritization decisions based on this. Though this is a little bit easier if we know what element is causing a network request rather than just what type. This way we can do things like and prioritize scripts/stylesheets that are blocking over ones that are not, and prioritize visible images over ones that are "below the fold". The latter one is a dynamic property which might change as reflows and scrolling happens. Fortunately HTTP/2 supports adjusting priorities dynamically. But I think this is something that we can track using internal state in the Request object most of the time. But associated a Request and an Element sounds useful to enable at some point. Though obviously this is hard to do inside a SW given that we can't expose Element references. For things that originate from within the service worker this seems a bit harder since I suspect that often times the SW will be just fetching resources ahead of time and thus all requests should have a low default priority. Though once a partial Response is returned as a result to a "fetch" event, we can adjust priorities as needed. Caching Pre-processed dataSimply having the information "this is likely going to be used as a script" would enable the platform to pre-process the resource in order to make using the resource faster. For example we could precompile JS, or convert an image into a format that can be sent directly to the GPU. This preprocessed data can then transparently be cached along with the network response whenever the page stores the response in the Cache API. Caching only pre-processed dataEven better, if we knew "this resource will only be used as a script" we could then drop the actual byte stream and only keep around the preprocessed data. This would mainly save us from having to write both the byte stream as well as the preprocessed data to disk. If we made it possible to provide more than a hint, and instead provide a promise "this will only be used as an image" when the Request is created, then we could forward that information to the Response object. I.e. the Response could indicate "this may only be used as an image", and any attempts to use the Response for something else would result in an error. |
If we allow This does seem to suggest to me that we should tie |
We managed to solve the MVP issue without exposing context (client was and still is out of scope). |
whatwg/fetch@3440a0a puts |
Fair enough to |
I would expect that if we move |
None of these are in scope for v1 |
I think the |
@jungkees, @jakearchibald is merging the concepts of service worker client and environment settings object. |
(Having said that, for now |
We resolved |
Should they be on
FetchEvent
orRequest
?FetchEvent
makes sense since as far as I can tell they only make sense in service workers.Request
makes sense since conceptually they are tightly coupled with the request (and actually part of underlying request).(Somewhat related: @jakearchibald has proposed
context
for ease of setting headers, but that would have to be a distinct feature. MaybeusageContext
, see #279.)The text was updated successfully, but these errors were encountered: