Open Bug 1691670 Opened 4 years ago Updated 1 year ago

Dynamically created <link rel="prefetch"> causes normal cache revalidation for subsequent real request

Categories

(Core :: Networking: Cache, task, P3)

Firefox 85
task

Tracking

()

UNCONFIRMED

People

(Reporter: fragster, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

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

Steps to reproduce:

Create webpack project with code splitting with prefetch/preload (see https://webpack.js.org/guides/code-splitting/#prefetchingpreloading-modules) for better performance.
It creates <link rel="prefetch" as="script" href="chunkname.js"> nodes using javascript

Actual results:

Firefox load chunks only on request, causing degradation of user experience compared to webkit based browsers

Expected results:

Preload chunks when page is idle state, like webkit based browsers

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

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core

Do you have a minimized test case on the Web?

Flags: needinfo?(fragster)

(In reply to Henri Sivonen (:hsivonen) from comment #2)

Do you have a minimized test case on the Web?

http://fragster.ru/ff/
src: https://github.com/FragsterAt/firefox_bug_1691670

Flags: needinfo?(fragster)

Thanks. I see the preload with "Initiator" as "other" in the Network panel of dev tools in Nightly on Linux.

(In reply to Henri Sivonen (:hsivonen) from comment #4)

Thanks. I see the preload with "Initiator" as "other" in the Network panel of dev tools in Nightly on Linux.

hmmmmmm

After googling I opened the about:config and found that network.prefetch-next was disabled. But I'm sure, that I didn't disable it (I didn't open about:config at all).
After enabling it, all works as expected.
Can it be turned off in another place?

In any case, when you click on the button, a request is made to the server, status 304 is returned. This can cause high delays on slow connections.
Headers in ff (after click): https://i.imgur.com/jF1ov4s.png
Timing: https://i.imgur.com/okHoWPs.png

In webkit browsers, the real request is not made, the status is displayed as "200 (from prefetch cache)".
Headers in chrome (after click): https://i.imgur.com/5mYawK0.png
Timing: https://i.imgur.com/1JUYAiL.png

Component: DOM: Core & HTML → Networking: Cache
Summary: Dynamically created <link rel="prefetch"> does not work → Dynamically created <link rel="prefetch"> causes normal cache revalidation for subsequent real request

(In reply to fragster from comment #5)

After googling I opened the about:config and found that network.prefetch-next was disabled. But I'm sure, that I didn't disable it (I didn't open about:config at all).
After enabling it, all works as expected.
Can it be turned off in another place?

These preferences can be tweaked by extensions:

I believe uBlock uses this API, but maybe some other extension does too?

This is a bigger project. We need to refactor prefetch code.

Type: defect → task
Priority: -- → P3
Whiteboard: [necko-triaged]
Blocks: rel=prefetch
Severity: -- → N/A
You need to log in before you can comment on or make changes to this bug.