Speculation rules prefetch delays navigation until the whole prefetched response body has downloaded
Categories
(Core :: Networking, defect, P2)
Tracking
()
People
(Reporter: acreskey, Assigned: acreskey)
References
(Blocks 1 open bug)
Details
(Whiteboard: [necko-triaged][fxpe])
Attachments
(1 external file)
When a click matches a speculation-rules prefetch that is still downloading, Firefox holds the navigation until the prefetch's whole body has arrived (the record only completes in PrefetchRecordParent::OnStopRequest). Without prefetch, the page would start rendering as soon as its first bytes arrive, so on pages with a slow-streaming body, enabling prefetch makes the page appear later. If the body takes over 2 s (dom.speculation_rules.wait_timeout_ms), the wait times out and the page is fetched again from scratch.
Per spec, the prefetch record completes once the response head arrives and the body streams (https://wicg.github.io/nav-speculation/prefetch.html#start-a-referrer-initiated-navigational-prefetch, step 15). Chrome serves the navigation at that point.
This is most likely with WordPress core's default conservative rule, which starts the prefetch at pointerdown, so the prefetch is nearly always still in flight at click time.
Reduced test: a target that sends headers at once and finishes its body after 1.2 s, linked from a page with a conservative document rule. Time from click to responseStart:
- Firefox, prefetch disabled: 9 ms
- Firefox, prefetch enabled: 1207 ms
- Chrome: 7 ms (served from prefetch)
Example site: on musicdel.ir (WordPress, conservative rule), clicking a link took 1.7-2.4 s longer in Firefox with prefetch enabled than with it disabled, in 3 of 3 runs; the wait timed out after the headers had arrived. Chrome served the same click from its prefetch in 0.35-0.73 s.
Bug 2071485 added the wait for an in-flight prefetch; bug 2080290 tunes the timeout. Neither covers waiting for the body once the headers have arrived.
| Assignee | ||
Updated•3 days ago
|
| Assignee | ||
Updated•3 days ago
|
Updated•3 days ago
|
Comment 1•1 day ago
•
|
||
With Bug 2093286, we will be imposing limits on how much data we can prefetch. Its important that we should lift those limits for the data as soon as we find a waiting navigational match.
| Assignee | ||
Comment 2•1 day ago
|
||
A navigation matching an in-flight prefetch waited for the whole prefetched
body, so a slow-streaming page rendered later than with prefetch disabled.
The prefetch record now completes at the response head, as the spec says, and
the navigation reads the prefetch's HTTP cache entry while it is still being
written. While that navigation is loading, the prefetch is neither canceled
nor held to the body cap, which would truncate the page.
| Assignee | ||
Updated•1 day ago
|
Updated•1 day ago
|
Description
•