Skip to content

What should transferSize, encodedBodySize and decodedBodySize in Navigation + Resource Timing represent for responses where a Service Worker is involved? #124

Closed
w3c/ServiceWorker
#1664
@abhishekcghosh

Description

@abhishekcghosh

The specifications for Navigation Timing API 2 or Resource Timing API 2 does not make it explicitly clear what is the definition or the expected value to be observed for transferSize, encodedBodySize and decodedBodySize parameters in both Navigation + Resource Timing APIs for responses that have been synthesised using a Service Worker.

The expected values are not clear either, considering how request interception through Service Workers opens up possibilities of zero-to-many fanout of actual network requests and subsequent response synthesis by combining resources from network and/or cache in any number of ways.

Should a page document (the service worker client) be aware of the actual network transfer costs for a request originating from it which can cause zero, one or more actual network request(s) based on Service Worker logic, or should it simply be opaque to all the Service Worker magic and consider whatever it received to be coming as if from the network? Sadly, none of these behaviour definitions has made clear sense to me so far, and there must be a better way of defining the behaviour here.

Current implementation on latest builds of a number of popular browsers (Chrome, Chromium, Firefox, Edge, Samsung Internet) seem to allude to this fact by simply reporting a "0" for all these parameters when a Service Worker is involved in between. A few examples of use-cases include:

  1. encodedBodySize or decodedBodySize for a resource that passes the timing-allow-check algorithm should not logically return 0, because there is a payload for those resources.
  2. Cache hit/miss checks based on the value of transferSize parameter is also thrown off in all these cases because it always returns 0 even if the timing-allow-check algorithm passes.

In effect, this means that today any website which uses a Service Worker (a large number of website do) will not be able to use certain important capabilities of the Navigation Timing or Resource Timing APIs correctly, which is a sad trade-off considering practical use-cases of website latency/performance improvements and metrics collection (in the process of doing so) can often tie website owners to a need of having to use these things together!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions