Open Bug 1854292 Opened 2 years ago Updated 1 year ago

Headers set during fetch() invalidate matching preloaded resource

Categories

(Core :: DOM: Networking, defect, P3)

Firefox 117
defect

Tracking

()

UNCONFIRMED

People

(Reporter: austin.donisan, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Attachments

(4 files)

Attached file preload-test.html

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

Steps to reproduce:

Preload a url using the Link tag. Request the url with fetch(), but including a custom header. Attached is a simple test case.

Actual results:

The preloaded resource is discarded and a 2nd request is made with the header specified in fetch().

Expected results:

The preloaded response should be returned by fetch() since headers aren't part of the matching algorithm for preloaded resources.

https://html.spec.whatwg.org/multipage/links.html#link-type-preload

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

Component: Untriaged → DOM: Networking
Product: Firefox → Core

fetch() doesn't work for local urls, so I hosted the test case to make this easier to verify:

https://server.hideaway-hotel.com/test2.html

Thanks for the report, can you submit some http logs for us to review?
You can use about:logging with the networking preset and log to file and upload here or email to necko@mozilla.com.
Thanks!

Flags: needinfo?(austin.donisan)
Flags: needinfo?(austin.donisan)
Blocks: fetch
Severity: -- → S3
Priority: -- → P3
Whiteboard: [necko-triaged]

This bug also happens to requests made with XMLHttpRequest, not just with fetch.

I just ran into this issue where Firefox was not consuming a preload because I was setting X-Requested-With header on the fetch() request.

Firefox seems to ignore Accept header when matching a preload.

The HTML spec does not mention that headers need to be matched to consume a preload, and Chrome fixed this in 2022: https://issues.chromium.org/issues/40685467#comment21

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: