Setting responseType to 'blob' causes double download when using link rel="preload" |
||||||
Issue descriptionSee reduced test case of this at https://github.com/andybons/preload On the page I have: <link rel="preload" href="/thing.json"> and then I construct my XMLHttpRequest to request /thing.json... var xhr = new XMLHttpRequest(); xhr.responseType = 'blob'; xhr.open('GET', '/thing.json', true); xhr.send(); Will cause /thing.json to download twice, with a console warning: The resource http://localhost:8080/thing.json was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it wasn't preloaded for nothing. However, removing the responseType line causes things to happen as expected, with no double download.
,
Dec 17 2016
Setting blob on XMLHttpRequest means that it is setting m_downloadingToFile on the ResourceRequest, which ResourceFetcher::determineRevalidationPolicy looks into in order to avoid reusing that resource. I'm not sure why that is...
,
Dec 19 2016
Setting m_downloadingToFile means the client is expecting that the response body is dispatched in the form of blob URL rather than bytes. So skipping MemoryCache is the intended behavior.
,
Dec 19 2016
yhirano - What happens when two different XHRs fetch the same resource as blob? Do we get two separate downloads? If so, is that intended as well?
,
Dec 19 2016
When m_downloadingToFile is specified, the response contains a URL for the blob body, but that URL will get stale after loading unless you manually protect it. Protecting the blob URL too much leads to resource leaks in the browser process, so I would like to avoid that if possible. Excluding preloading, XHR is not using the blink MemoryCache in order to reduce memory consumption: see issue 659789 .
,
Dec 19 2016
,
Dec 20 2016
Seems to be working as intended, changing status to get off of triage list.
,
Dec 21 2016
I disagree. I think the link preload case should be special cased. Assigning to myself.
,
Mar 29 2017
,
Oct 23 2017
Still happens (Chromium 61)
<link crossorigin rel="preload" href="file.json" as="fetch">
then later on:
fetch("file.json").then(status).then(json).then(function(data) { ... }
Results in:
1) double-fetch, first from preload (with type=json according to devtools) and later from javascript (with type=fetch)
2) Chrome's warning: XXX was preloaded using link preload but not used within a few seconds
,
Oct 23 2017
Similar issue with as="fetch" used for fetch HTML template content.
<link crossorigin rel="preload" href="results-template.html" as="fetch">
then later on:
$.get("results-template.html").done(function(html) { $("body").append(html); });
Results in:
1) double-fetch, first from preload (with type=text/html according to devtools) and later from javascript (with type=xhr)
2) Chrome's warning: XXX was preloaded using link preload but not used within a few seconds
,
Mar 9 2018
This seems to be still an issue with Chromium 64. I came here from https://stackoverflow.com/questions/41655955/why-are-preload-link-not-working-for-json-requests; right now it seems preloading JSON simply doesn't work at all in Chromium, 'blob' or not.
,
Mar 9 2018
Sorry, I wasn't really clear. What I meant to say was that the issue description says: > However, removing the responseType line causes things to happen as expected, with no double download. But for me it doesn't work even with the responseType line removed. Can anybody confirm this ever worked, and with what Chromium version, so we know whether this is a regression?
,
Mar 9 2018
That is, in the current form, the repro at https://github.com/andybons/preload, using `without.html`, prints: <link rel=preload> must have a valid `as` value that's why it doesn't double-load. If you add the required `as="prefetch"`, then it double-loads with Chromium 64, so what's written in the issue description doesn't work at least in my Chromium. |
||||||
►
Sign in to add a comment |
||||||
Comment 1 by esprehn@chromium.org
, Dec 17 2016Components: Blink>Loader