-
Notifications
You must be signed in to change notification settings - Fork 36
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
Reflect preload information (in ResourceTiming?) #303
Comments
The downside of an explicit entry for the preload-reuse resource is that it's a change from what happens today, so it might be worthwhile to run it by RUM folks and see how much confusion it's likely to create. |
It won't always be different from how it is today. It depends on the status of the cache at that moment. And in any case it would be a near-zero-time entry. |
Also, "what happens today" is different across browsers :) If we go with a clear definition of preload (like here) and a clearer definition of what an RT entry represents (we said in the F2F that it should represent a fetch), then a preload and a preload-consume are two fetches, the second one reusing a cloned response from the first one, which would generate two resource timing entries (one with initiatorType "link" and one with initiatorType "img" or whichever resource), the second of which would be zero-ish. |
From an RT perspective I think preload should behave as fetches from the pre-parser do as it's essentially the same behaviour - a resource is fetched ahead of time, and used later - one is browser initiated, and the other author initiated So if preload results in two RT entries then everything that's fetched by the pre-parser should also result in two entries - which I think would be very weird I think the RT entry for preload should match the network or HTTP cache fetch as it does for other resources and the reporting API used to flag unused preloads Won't provide information via RT that's something is used but will flag up non-used ones |
But the preparser has a substantial difference, e.g. you know the element that's going to use the resource and that early fetching is not entirely observable, e.g. it has the same initiatorType which is not info available to preload.
I don't think having two entries for preload should necessarily mean two entries for the preparser
Sure, that's also an option |
Actually based on the newer developments in the preload PR, I tend to agree with either having some "unused preload" flag (maybe something like |
Proposal:
This is in line with navigation timing, where the entry is created when we know about it, but only gets queued when its final attribute is set. It also allows us to report unused preloads in RUM without adding a timeout - a RUM library or a document can check on its own whether we have preloaded links that don't match RT entries with corresponding WDYT, @andydavies @yoavweiss |
I like it! |
The proposal seems reasonable to me, but it's unclear from the discussion in the thread what the current behavior is and why we need to change it. Can this be documented here? |
The current behavior doesn't mark the time the preload was consumed, and you'd need to guess whether it's consumed based on the existence of another RT entry with the same URL. The idea was to give extra indication about use of preloads, which is a request that came in the preload discussion at TPAC. Note that this changes the current behavior in a minor way only - the attributes for the preloaded entry stay the same and a new one is added - the only actual change in behavior is that the preload is not queued until consumption. |
@noamr I like your proposal. Two potential challenges though:
I generally don't like tying things to the |
Suggesting that the initiator type of link headers would be
They will have an RT entry, but it wouldn't be queued to PerformanceObservers. |
If the RT entries are there but not queued to observers, is this needed? Simply check |
I think the original idea of having an RT entry for consuming a resource, and differentiating it from the preload entry somehow would be more straightforward - e.g. having a |
There was the suggestion that RUM providers could cross-check their HTML-based
Hm, I don't think we have any precedence for PerformanceObservers "seeing" a different view than |
Right. Suggesting that they could cross-check against preload entries in the RT buffer instead.
they're seeing the same view but not necessarily get triggered for each entry. |
Ah yep, agreed that would work.
I see, you're suggesting RUM would:
I can see how that would work, but thinking through a few small gotchas:
That's fair. It's helpful for NT that it's the "only" entry in the NT PO buffer (for now), so I think it's a bit easier for developers to know that caveat. I'm concerned that developers would get confused in general that the PO and PT buffers may be slightly different for Preload reasons. If we did this, we may want some additional guidance/notes in the spec. Will ponder this a bit more though! |
Has there been any discussion of using the reporting-api to tackle this e.g. report unused preloads to an endpoint rather than having two performance entries? (did wonder whether bfcache reasons should adopt the same thing) (Before I test this) do you know how the browser having to go to cache twice for the same resource is recorded in RT e.g. image gets evicted from memory on a low powered device and browser has to refetch it from cache when visitor scrolls of such like? |
This is not just about unused preloads, it's also for preloads that are used a long time after they're loaded, to help optimize... maybe you didn't need to preload it because anyway it's used very late?
yes retrieving from HTTP cache is reflected, with |
I understand the concerns... the alternative would be to have an additional RT entry for the consume. I will present the options in one of the following WG meetings, would be good to hear more thoughts here in the meantime. |
So if I load a page that has an image at the top, scroll to the bottom and the image gets evicted from memory cache, scroll back to the top and the browser reloads the image from cache I'll get two RT entries - one potentially with a transferSize and one without? |
That is correct. |
Two alternatives: (feel free to propose more) Separate Entry
Additional Property
|
Right now it's impossible to know whether a resource was used as part of a preload.
Preloading the resource would generate the RT entry, and in some cases it would be reused without a new fetch (e.g. if it's in the image cache), and in some cases there would be a new fetch that would go to cache (with
transferSize
0).Suggesting to be explicit about it, and to say in a subsequent fetch whether it was served from network, service-worker, HTTP cache, or preload.
The text was updated successfully, but these errors were encountered: