Skip to content
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

103 Early Hints response processing during navigation #7598

Closed
bashi opened this issue Feb 10, 2022 · 6 comments · Fixed by #7675
Closed

103 Early Hints response processing during navigation #7598

bashi opened this issue Feb 10, 2022 · 6 comments · Fixed by #7675

Comments

@bashi
Copy link

bashi commented Feb 10, 2022

A 103 Early Hints response is an informational response a server can send before the final response to give a client some hints to optimize rendering pages (e.g. preloading critical subresources such as JS and CSS). For details about the motivation and use cases, please refer to the explainer. TAG review was completed.

103 are typically useful for navigation. We would like to specify 103 processing in the process a navigate fetch algorithm.

We’d propose the following changes in the Fetch standard and the HTML standard:

  • [Fetch] Add a new optional argument processEarlyHintsResponse to the fetch operation. It takes an algorithm that will be passed a header list coming from a 103 response. Indicates a 103 response has been received. The value is plumbed via fetch params.
  • [Fetch] Update the HTTP-network fetch algorithm. Stop ignoring 103 if processEarlyHintsResponse is given. Instead, retrieve a header list from a 103 response and queue a fetch task given fetchParam's processEarlyHintsResponse and the header list.
  • [HTML] Pass processEarlyHintsResponse in the process a navigate fetch algorithm (Step 5.1). Details of the steps need to be discussed (see below).

whatwg/fetch#1225 is the tracking issue for the Fetch standard changes.

Topics to discuss

The following topics should be discussed as next steps if the above proposal makes sense.

cc/ @yutakahirano @yoavweiss (Please cc relevant people)

@annevk: What do you think?

@yoavweiss
Copy link
Contributor

/cc @noamr

@yutakahirano
Copy link
Member

cc: @ddragana

bashi added a commit to bashi/fetch that referenced this issue Feb 17, 2022
Plumb an algorithm to process 103 Early Hints responses. The
algorithm is optional.

See whatwg/html#7598 for the overall
approach.
@annevk
Copy link
Member

annevk commented Feb 28, 2022

I think overall this sounds reasonable. I think the tricky bit is figuring out the policy container to be used for any fetches resulting from the 103. How will we deal with CSP, referrer, sandboxing, etc.

Another challenge here is that currently Fetch is handed a "client" which doesn't really work for this. (Arguably that setup needs some changes anyway as Fetch needs to pull of what it needs before it goes in parallel and I'm not sure it does for everything.)

@noamr
Copy link
Collaborator

noamr commented Feb 28, 2022

I think overall this sounds reasonable. I think the tricky bit is figuring out the policy container to be used for any fetches resulting from the 103. How will we deal with CSP, referrer, sandboxing, etc.

Another challenge here is that currently Fetch is handed a "client" which doesn't really work for this. (Arguably that setup needs some changes anyway as Fetch needs to pull of what it needs before it goes in parallel and I'm not sure it does for everything.)

Conceptually, I suggest that a 103 would be somewhat equivalent to a prefetch by a document from the same origin as the navigation (which is also yet to be fully specified.

Something like:

  • A 103 response arrives
  • For the first 103, create a fake prefetching document with the URL of the response
  • Assign to that document the CSP known so far, e.g. CSP received by this or other 103 responses
  • Once the real document is created and initialized, apply the headers again as if they were regular link headers.

(... not sure if the spec needs to involve this fake document in practice, but I'm suggesting it should behave in an equivalent manner)

@noamr
Copy link
Collaborator

noamr commented Mar 1, 2022

Thinking about this more, I believe we are going to need that fake document and environment settings object, which would resolve some fetch-related questions.

@noamr
Copy link
Collaborator

noamr commented Mar 2, 2022

Another challenge here is that currently Fetch is handed a "client" which doesn't really work for this. (Arguably that setup needs some changes anyway as Fetch needs to pull of what it needs before it goes in parallel and I'm not sure it does for everything.)

I think our friends here are creating a policy container from a fetch response and reserved client. We might not need a fake document if we piggy back on those.

annevk added a commit to whatwg/fetch that referenced this issue Apr 7, 2022
Allow specifications to pass an algorithm to fetch to process 103 Early Hints responses.

See whatwg/html#7598 for the overall approach.

Corresponding HTML PR: whatwg/html#7675.

Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
domenic pushed a commit that referenced this issue Apr 14, 2022
mfreed7 pushed a commit to mfreed7/html that referenced this issue Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

5 participants