<link rel="prefetch"> resources are competing with main page resource downloads
Reported by
spadmana...@ebay.com,
Sep 28 2016
|
||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 Example URL: http://senthilp.github.io/playground/ Steps to reproduce the problem: Link prefetching (<link rel="prefetch">) resources are interfering with the with main page resource downloads. As per the docs (https://developer.mozilla.org/en-US/docs/Web/HTTP/Link_prefetching_FAQ), browsers should download the prefetch resources only after the main page finished loading and when the browser is idle. Also it should not compete for bandwidth with the main page resources. In this example http://senthilp.github.io/playground/ we are seeing the prefetch URLs start to download along with images and async script <script async> tags. CSS and regular script (<script>) resources are given higher priority, but not others (see attached screenshot). Below is the order of resource downloads 1. CSS 2. scripts (sync) 3. Prefetch URLS 4. images 5. scripts (async) Programmatically adding link prefetch URLs in window load event seem to solve the problem, as we are forcing a delayed download. Sample URL - http://senthilp.github.io/playground/script Code - https://github.com/senthilp/playground/blob/gh-pages/script.html#L143-L154 But not sure if that is an ideal solve. The preference is to use the declarative approach. What is the expected behavior? Prefetch downloads should wait until the main pages loading is complete and the browser is idle. What went wrong? Prefetch URLs are competing with the main page resources, in particular images. Images are critical to provide an optimal user experience and we do not want prefetch resources to share bandwidth with them. Did this work before? N/A Chrome version: 53.0.2785.116 Channel: stable OS Version: OS X 10.11.6 Flash Version: Shockwave Flash 23.0 r0
,
Sep 28 2016
I can recreate the issue locally. Thanks for the test case! :)
,
Sep 28 2016
BTW, this works as expected in Firefox. Also prefetch doesn't seem to honor cache headers i.e. Chrome caches the response even if there are no cache headers. Should I file a separate issue for it?
,
Sep 28 2016
Chrome caches prefetched resources for a short period even if they're non-cacheable (to avoid double downloads)
,
Sep 28 2016
So the priority seems to be set (as it should be) to "very low", but gaps in resource discovery mean that these resources go out before higher priority resources that are discovered later. One way to go about this is to pipe the prefetch info all the way to ResourceScheduler (since there are other VeryLow resources) and then add some kind of fixed delay since last request before sending out prefetch requests. Nate/Charlie/Pat - does that make sense?
,
Sep 28 2016
I would prefer throttling the prefetch in the renderer. Blink should know we are early in a page load and there are other critical resources coming. Worst case I wouldn't be opposed to send these out at DCL. Note that we shouldn't be adding any more logic to ResourceScheduler, because rdsmith is in the process of removing it.
,
Sep 28 2016
A few thoughts off the top of my head: - We should probably just queue them up in the renderer until the load event and only pass them through then. That way there's no races and it's guaranteed to have loaded all of the main resources. - Right now, VeryLow just get a lower priority than other requests but if they are on a separate host they will still contend (up to the 10 concurrent low priority resources at a time). If we really want them to only go out during idle times we need to plumb that logic and it might need a discrete priority for "Idle" - As far as caching in general, "no" caching headers means browsers can use heuristics (custom logic aside for prefetch). If you don't want things generally cached you need to be explicit with a no-cache directive.
,
Sep 28 2016
Delaying till DCL (or even onload) makes sense. And if we're doing that, keeping this logic in the renderer would certainly simplify things. Thanks!
,
Sep 28 2016
I'd recommend onload over DCL. DCL will still compete with the images that this specific case is trying to avoid.
,
Nov 8 2016
,
Nov 8 2016
Issue 652746 (loosely prerenders aren't completing quickly enough, priority should be raised above IDLE) might also be of interest to folks on this bug. That issue is closed, but discussion is still ongoing about whether/how to extend the Android fix (which was to raise the priority) to other platforms.
,
Jan 31 2017
I would be supportive of delaying until onload (instead of DCL). Has a decision been made on which of these points we want to move ahead with on this particular issue?
,
Jan 31 2017
I'm working on requestResource refactoring that's required in order to split prefetch request processing from the actual loading: https://codereview.chromium.org/2660213003/
,
Mar 29 2017
,
Apr 10 2017
I have a WIP patch to resolve this at https://codereview.chromium.org/2751973005/ but csharrison@ rightfully argued that it may regress certain usage patterns. I'm starting to think this might require some explicit control that'd enable Web developers to express their preference one way or the other.
,
Feb 16 2018
,
Jul 30
,
Dec 12
Yoav, are you actively working on this? If not, do you mind if we take this over?
,
Dec 12
,
Dec 12
,
Dec 13
cc his new chromium account just in case
,
Dec 13
This has been stagnant as we had no good ideas on how to resolve this without regressing some of the use-cases. If you have ideas on tackling that, or if the urgency here is higher than it used to be, please let me know. |
||||||||||||
►
Sign in to add a comment |
||||||||||||
Comment 1 by y...@yoav.ws
, Sep 28 2016