Skip to content

Clarify nextHopProtocol value for cached fetch, part 2 #419

@nicjansma

Description

@nicjansma

Per the current ResourceTiming spec (in alignment with Fetch), it's not obviously clear (to me) what nextHopProtocol should be in cases of a cache hit.

Intuitively, I was expecting nextHopProtocol to be empty if it was a cache hit, similar to how transferSize is 0.

For transferSize, the ResourcTiming spec has a callout:

Image

However, there's no similar callout for nextHopProtocol. Instead, it's defined in terms of Fetch's connection info object:

The nextHopProtocol getter steps are to isomorphic decode this's timing info's final connection timing info's ALPN negotiated protocol. See Recording connection timing info for more info.

That links out to these sections of Fetch:

It's a bit hard to follow everything, but it feels like if no new connection was established (due to a cache hit) then either the "timing info" should be null, or, its' nextHopProtocol should be null. Both cases suggest nextHopProtocol field should then be null.

In practice, today, Chrome and Firefox both give the nextHopProtocol of the fetch from when it was put into the cache, instead of empty string.

Repro: https://dev.nicj.net/nexthopprotocol-transfersize.html

ResourceTiming fetch(): 1757979699716 proto: h2 transferSize: 0
NavigationTiming: 1757979699720 proto: h3 transferSize: 0

(I had opened a Mozilla bug against this, triggering this clarifying question: https://bugzilla.mozilla.org/show_bug.cgi?id=1905759)

Looking back, pre-Fetch integration, we had a similar discussion:

#73

Which was resolved by adding spec language noting that nextHopProtocol should be empty string in cache hits:

#78

I think that may have been lost in the Fetch realignment.

I propose we add a similar language for nextHopProtocol in ResourceTiming to enforce it being null in cache. Alternatively, it might be possible to make this more clear in the Fetch spec, but that seems more roundabout.

Thoughts?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions