WICG / nav-speculation

Proposal to enable privacy-enhanced preloading
https://wicg.github.io/nav-speculation/
Other
151 stars 35 forks source link

Clarify 103 response code support #339

Open tunetheweb opened 5 days ago

tunetheweb commented 5 days ago

Was asked if 103 early hints prevents navigation speculation. We tested and they don't (at least for prefetch), as it's the final response status that counts, but it could maybe be made clearer in the spec which has things like this:

A response response supports prefetch if the following steps return true:

  1. Let status be response’s status.
  2. Assert: status is not a redirect status.
  3. If status is not an ok status, then return false.
  4. Return true.

With a link to fetch's definition of ok-status:

2.2.3. Statuses A status is an integer in the range 0 to 999, inclusive. A null body status is a status that is 101, 103, 204, 205, or 304. An ok status is a status in the range 200 to 299, inclusive. A redirect status is a status that is 301, 302, 303, 307, or 308.

204 and 205 have special exclusions in the spec for prerendering, 304 is not yet supported as per #330, 101 is not really revelant for prerendering navigations, which leaves 103 as kind of unclear.

Given both 103 Early Hints and Nav Speculations are performance optimizations it would be good to be clearer about this.

domenic commented 5 days ago

The issue is that the 103 is completely done with by the time we actually hit the navigation code; it's handled at a lower layer and that part of the spec never sees it.

So if a 103 somehow did get to that line in the spec, it would be correct to fail. Although that should never be possible.