w3ctag / design-reviews

W3C specs and API reviews
Creative Commons Zero v1.0 Universal
330 stars 55 forks source link

deliveryType (Resource Timing) #858

Closed jeremyroman closed 9 months ago

jeremyroman commented 1 year ago

こんにちは TAG-さん!

I'm requesting a TAG review of deliveryType (part of Resource Timing).

Resources on the web are usually fetched via HTTP (from the origin server), but in some cases they are known to be delivered from a cache or other buffer, in a way that affects loading performance. Insight into this is useful for authors understanding when these caches accelerate resource loading. The deliveryType attribute on PerformanceResourceTiming addresses this, with the following values: "" (no more specific delivery type applies), "cache" (the resource was served from the cache), "navigational-prefetch" (the resource was prefetched for navigation from another page).

Further details:

We'd prefer the TAG provide feedback as (please delete all but the desired option): 💬 leave review feedback as a comment in this issue and @-notify @jeremyroman

jeremyroman commented 1 year ago

Anticipating one possible question -- the type of the attribute is DOMString. Since this values is only provided to clients and not accepted from them, I believe this is indistinguishable from an enum from the author's perspective, and was chosen for consistency with most other values exposed on this object.

If an enum would be preferred (I believe this is still forward-compatible for the addition of new types in the future), that seems like a change that would be possible to make to the specification without any change to author code.

hober commented 1 year ago

Since there are more than one kind of cache, is the single "cache" value sufficient?

atanassov commented 1 year ago

An effort that needs to be considered is the Sustainability of Bundling and Caching. In case that privacy approach becomes adopted your proposed API should probably apply similar heuristics and "masking" of the results.

jeremyroman commented 1 year ago

There are many kinds of cache, yeah. In the context of PerformanceResourceTiming I think it's most natural to describe the HTTP cache (whether it has one layer or multiple), and that's what people usually seem to mean by "the cache" in this context.

Some caches (e.g., an image decode cache) probably don't make sense to describe as part of resource loading.

Some caches (e.g., a caching forward proxy, reverse proxy or CDN) are outside the user agent proper and I would think probably don't make sense to describe here (but server timing might be appropriate). If we did want to describe it in deliveryType in the future, I think it would be natural for it to have a different enumerator.

The service worker and preload caches are probably the two most potentially interesting cases I'm aware of. Consuming resources from the preload cache isn't currently exposed, and if it were to be (w3c/resource-timing#303), I think a separate enumerator would be justified and would be reasonably clear, since it's generally not described as a "cache" elsewhere in its API (deliveryType: "preload" or similar).


re. sustainability of bundling and caching, there doesn't seem to be enough detail there yet to strongly reason about its implications if adopted, but if it becomes necessary to obscure the cache state of certain resources I agree that similar masking might be applicable here. I would hope that at same-origin resources, at least, wouldn't require such masking.

ylafon commented 9 months ago

Sorry it took a long time to close this, but as hinted above, we don't have any issue with this.