New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 651160 link

Starred by 5 users

Issue metadata

Status: Started
Owner:
Last visit > 30 days ago
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

<link rel="prefetch"> resources are competing with main page resource downloads

Reported by spadmana...@ebay.com, Sep 28 2016

Issue description

UserAgent: 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
 
Screen Shot 2016-09-28 at 11.09.37 AM.png
236 KB View Download

Comment 1 by y...@yoav.ws, Sep 28 2016

Cc: igrigo...@chromium.org y...@yoav.ws

Comment 2 by y...@yoav.ws, Sep 28 2016

Cc: -y...@yoav.ws
Owner: y...@yoav.ws
Status: Assigned (was: Unconfirmed)
I can recreate the issue locally. Thanks for the test case! :)
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?

Comment 4 by y...@yoav.ws, Sep 28 2016

Chrome caches prefetched resources for a short period even if they're non-cacheable (to avoid double downloads)

Comment 5 by y...@yoav.ws, Sep 28 2016

Cc: pmeenan@chromium.org japhet@chromium.org csharrison@chromium.org
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?
Cc: rdsmith@chromium.org
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.
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.

Comment 8 by y...@yoav.ws, 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!
I'd recommend onload over DCL.  DCL will still compete with the images that this specific case is trying to avoid.
Components: Blink>Loader
 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.

Comment 12 by addyo@chromium.org, 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?

Comment 13 by y...@yoav.ws, Jan 31 2017

Status: Started (was: Assigned)
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/

Comment 14 by addyo@chromium.org, Mar 29 2017

Cc: addyo@chromium.org

Comment 15 by y...@yoav.ws, 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.
Cc: -rdsmith@chromium.org
Cc: -pmeenan@chromium.org
Yoav, are you actively working on this? If not, do you mind if we take this over?
Components: Blink>Loader>Preload
Labels: -OS-Mac OS-All
Cc: ryansturm@chromium.org buettner@chromium.org
Cc: yoavweiss@chromium.org
cc his new chromium account just in case
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