Closed Bug 1755227 Opened 2 years ago Closed 5 months ago

HTTP Link rel=prefetch header doesn't initiate request for assets until AFTER the page body is complete

Categories

(Core :: Networking: HTTP, defect, P2)

Firefox 97
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: davy.wybiral, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0

Steps to reproduce:

A server responds with the following HTTP:
HTTP/1.1 200 OK\r\n
Link: </theme.css>; rel=prefetch\r\n
Content-Type: text/html; charset=utf-8\r\n
\r\n
[ PAGE BODY HERE ]

Actual results:

The request to /theme.css isn't initiated until AFTER the browser has closed the main connection no matter how long it takes for the page body to download. This means that the entire page body must be sent before it even attempts to request the "prefetch" asset.

Expected results:

The browser should be able to prefetch the asset while the page is being loaded instead of waiting for the main connection to complete, otherwise it probably doesn't add much benefit (aside from marginally getting ahead of the HTML parse time).

Chrome, for instance, starts making Link rel=prefetch requests as soon as the header section of the HTTP response is sent so it can happen concurrently to the body of the request being downloaded.

Additionally (and I can open a specific bug for this if it's not related) Link rel=prefect assets appear to break entirely if their response uses Transfer-Encoding:chunked. The browse seems to only allow 2 chunks in the body before aborting the connection.

I can provide example server code and tests if it helps.

The Bugbug bot thinks this bug should belong to the 'Core::Networking: HTTP' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Networking: HTTP
Product: Firefox → Core
Blocks: rel=preload
Severity: -- → S4
Priority: -- → P2
Whiteboard: [necko-triaged]

From spec:

The prefetch keyword indicates that preemptively fetching and caching the specified resource or same-site document is likely to be beneficial, as it is highly likely that the user will require this resource for future navigations.

Prefetch sematic tells us that the resource is for the next navigation, not for the current page. What you are looking for is rel=preload.

For the Transfer-Encoding chunked we should open a separate bug (I'll see if I can find an open one or we should open a new one).

Status: UNCONFIRMED → RESOLVED
Closed: 5 months ago
Resolution: --- → INACTIVE
Resolution: INACTIVE → INVALID
Blocks: rel=prefetch
No longer blocks: rel=preload
See Also: → 1866455
You need to log in before you can comment on or make changes to this bug.