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

initiatorType definition doesn't define initiator in multiple element scenarios #54

Open
yoavweiss opened this issue May 23, 2016 · 10 comments

Comments

@yoavweiss
Copy link
Contributor

While digging around WebKit's resource timing code, I realized that initiatorType is not well defined in scenarios where the same resource is requested by multiple initiators.

e.g. If an image is requested first by <img> and later on by a CSS url(), which initiator type should it have? To me it makes sense that it would be defined to be based on the first element that initiated that fetch, so in the above scenario it would be "img" rather than "css".

@yoavweiss yoavweiss changed the title Should initiatorType override previous values? initiatorType definition doesn't define initiator in multiple element scenarios May 23, 2016
@yoavweiss
Copy link
Contributor Author

I wrote up a short test at http://jsbin.com/tanuweletu/1/edit?html,console

It seems like Firefox maintains "img" in that field, similar to WebKit's (not-yet-shipped) implementation. Blink's implementation OTOH is flaky and results in either "img" or "css" :/

@igrigorik
Copy link
Member

If an image is requested first by and later on by a CSS url(), which initiator type should it have?

Personally, I'd expect it to report "img" for the first request and "css" for the second. The fact that the latter may have been served from one of many caches (memory, serviceworker, http, whatever) is completely orthogonal.. What matters here is who initiated the fetch, not whether it hit the network.

@toddreifsteck
Copy link
Member

My expectation matches @igrigorik

@toddreifsteck
Copy link
Member

Note that Microsoft Edge is "img" and only lists 1 resource timing.

My 100% guesstimate on the basic structure of why most browsers would see 1 resource timing is that one download or the other kicks the download then the other one waits on the file until it completes. The "download" code is most likely recording the resource timing.

@yoavweiss
Copy link
Contributor Author

It's not a second fetch served from one of the caches. The CSS url() is reusing the same resource object (similar to multiple <img> tags with the same src value).

@igrigorik
Copy link
Member

But the reused resource must come from somewhere, right.. a shared cache? In this instances it's probably the memory cache, but it also doesn't have to be - e.g. evicted and falls through to HTTP cache.

Fetch does not "explain" memory caches today, it should.. This is also related to w3c/preload#30.

@yoavweiss
Copy link
Contributor Author

It is coming from the memory cache, but I don't think we want to expose each call to the memory cache in resource timing. (e.g. that's also where the preloader is placing preloaded resources, and where later DOM nodes find them when they are needed)

FWIW, HTML has a concept of "list of available images" that touches on the memory cache a little (as some of the behavior there is Web exposed). But I totally agree that it should be more explicitly explained.

@igrigorik
Copy link
Member

It is coming from the memory cache, but I don't think we want to expose each call to the memory cache in resource timing...

I'm not saying we should expose calls to the memory cache. Rather, something triggers a request... that something is the initiator. Whether the response for this request comes from memory/http/whatever cache is beside the point. Also, there are probably some potentially privacy issues with leaking the "first" initiator for subsequent requests..?

@igrigorik
Copy link
Member

@yoavweiss assigning you as owner on this; I believe you had an AI from the F2F to write up how different browsers behave, what we want to see, etc?

@igrigorik igrigorik added this to the Level 3 milestone Jun 29, 2016
@noamr
Copy link
Contributor

noamr commented Apr 11, 2022

This is yet another side effect of the memory cache not being defined.

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

No branches or pull requests

4 participants