-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
How does a list of available images used when parsing document with multiple img nodes with same src? #2465
Comments
Those browsers are presumably relying on the HTTP cache which contains an in-progress response. |
Interestingly, this ain't gonna happen if you simultaneously send multiple GET requests to same URI using |
I add |
This is specified: https://html.spec.whatwg.org/#the-list-of-available-images Closing but happy to continue discussing in the closed thread, and reopen if we missed something in the spec. |
@domenic isn't that correct that according to standard parsing of following piece of HTML should end up performing two network requests? Given browser sees URI of the
|
@LeonidVasilyev it's not correct, for images in particular, due to the map @domenic referenced. |
@annevk my reasoning is based on two pieces of HTML standard. 14 step in 4.8.4.3.4 Updating the image data states that image is added to list of available images after it is fetched:
First note from 4.8.4.3.3 The list of available images states that list of available images is not used to avoid re-downloading image while it's still loading:
In my example when parser sees second Please correct me if I wrong or missed something. |
That's probably an error of sorts, or maybe the difference between Chrome/WebKit's memory cache and this HTML feature. |
I think what happens here is that Chrome decides to not make a second image request to that URL while the first one is in progress. That isn't governed by the spec I guess, and might technically be against spec depending on how you read things. Then when it comes time to make the second request, it goes through the logic to check the list of available images, and the spec takes over. I believe @surma was doing some research on this? |
I was doing some research on behavior discrepancies between browsers when it comes to If you request resource In the context of This behavior differs wildly across browsers – but none of them violate the HTTP spec for caching, they are just suboptimal at times. Not sure this is necessarily helpful for this discussion – but I see stalling a second request to wait for the first one not as a violation of the HTML spec. |
Isn't this behavior the same for other things, like fonts, stylesheets, scripts? The intent as far as the spec for |
Only WebKit/Chrome have this so-called "memory cache" as I understand it. I've asked some folks to describe it and get it standardized, but not much activity thus far. |
Couple more test cases:
Altough Firefox has a flag named browser.cache.memory.enable it doesn't seem to affect browser behavior in described scenarios. |
@LeonidVasilyev: What are the caching headers on those resources? According to my research, they do have an impact on how the browser behaves: serialize = last request has to finish before next request is kicked off |
@surma, I've got same result for Chrome, Firefox and IE 11 with both |
Wow, that’s giving me a headache. I’ll take a closer look at this in the coming weeks. Whatever the underlying mechanism, this is not good in terms of developer ergonomics. |
Refresh image with a new one at the same url discussion on StackOverflow contains interesting information about in-memory cache or list of available images behavior. According to Aya's answer you should use both |
I'm testing this in Chrome using a local express server. I have 1000 img elements in an html doc.
Weird that a delay on the |
Standard states following regarding list of available images:
However, if you open an HTML document that contains multiple
img
nodes with samesrc
in current versions of Chrome, Firefox or IE 11 you will notice that these browsers make only single network request for that image.I checked this test case in serveral browsers:
Is this a deviation from standard or a side effect from some behavior specified by HTML standard?
The text was updated successfully, but these errors were encountered: