Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple <link rel=preload>s with the same preload key appear to cause multiple requests #10786

Closed
domenic opened this issue Nov 21, 2024 · 4 comments

Comments

@domenic
Copy link
Member

domenic commented Nov 21, 2024

What is the issue with the HTML Standard?

Reading the spec in https://html.spec.whatwg.org/#link-type-preload , I am pretty sure that

<link rel=preload as=image href=foo.png>
<link rel=preload as=image href=foo.png>

requires doing two fetches. If I am reading the Fetch spec right, the second one might even consume the preload response from the first one?

This seems like a bug. @noamr, do you agree?

I know there are more general issues around to what extent the "memory cache" is specified. But my understanding was that @noamr's work on <link rel=preload> was intended to start putting us on solid footing there. So maybe tackling just this particular case first is worthwhile.

/cc @nidhijaju

@noamr
Copy link
Contributor

noamr commented Nov 21, 2024

What is the issue with the HTML Standard?

Reading the spec in https://html.spec.whatwg.org/#link-type-preload , I am pretty sure that

<link rel=preload as=image href=foo.png>

<link rel=preload as=image href=foo.png>

requires doing two fetches. If I am reading the Fetch spec right, the second one might even consume the preload response from the first one?

This seems like a bug. @noamr, do you agree?

I know there are more general issues around to what extent the "memory cache" is specified. But my understanding was that @noamr's work on <link rel=preload> was intended to start putting us on solid footing there. So maybe tackling just this particular case first is worthwhile.

/cc @nidhijaju

The second preload consumes the first preload, and the following fetch will consume the second preload.
So this works as intended I think?

@domenic
Copy link
Member Author

domenic commented Nov 22, 2024

Yeah, I think you're right. And that's not really observable, so an implementation could optimize it by just not doing the second preload, I think?

@domenic domenic closed this as completed Nov 22, 2024
@noamr
Copy link
Contributor

noamr commented Nov 22, 2024

Yeah, I think you're right. And that's not really observable, so an implementation could optimize it by just not doing the second preload, I think?

It's observable in resource timing, we have a WPT for that IIRC but I am not sure about the interop of this in particular, it's been a while. Happy to check.

@domenic
Copy link
Member Author

domenic commented Nov 22, 2024

Hmm OK. @nidhijaju is looking into optimizations here where we want to skip doing redundant things, but I don't think this particular case of multiple preloads showed up in the real world. (It just came to my mind while we were discussing a more realistic scenario.) So I think we'll be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants