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

Expose Content-Encoding to ResourceTiming #381

Open
nicjansma opened this issue Sep 16, 2023 · 11 comments · May be fixed by #385
Open

Expose Content-Encoding to ResourceTiming #381

nicjansma opened this issue Sep 16, 2023 · 11 comments · May be fixed by #385

Comments

@nicjansma
Copy link
Contributor

Hi,

Similar to request #203 to expose Content-Type, I would like to request exposing the Content-Encoding of each resource to ResourceTiming.

As we're starting to see experimentation and deployments of new content encodings such as Zstandard (zstd) and compression dictionary transports (zstd-d and br-d), we are moving toward content being delivered from a large set of possible encodings, even to the same client on different page loads or (sub)requests to the same domain.

When the content encoded was a small set: (none), gzip and brotli, one could often infer the encoding depending on the encoded/decoded body sizes, though that generally only works if one "owns" the content (has visibility into what the size would be for each encoding type).

Having an explicit .contentEncoding would help with some use-cases I can think of:

  • As origins and CDNs want to experiment with new Content Encodings, they could utilize phased rollouts of the above technologies and be able to segment (from RUM) the performance of clients utilizing those new technologies.
    • For example, this can help with understanding real-world uptake %, how the performance behaves for those new technologies, and debugging them
  • Once fully deployed, origins and CDNs could segment browsing sessions (or A/B test) with those technologies to provide value confirmation and/or debugging via RUM.
    • For example, one could verify with RUM (along serverside logs) how often dictionaries are being used.
  • Third-party RUM vendors could segment resource fetches by their encoding with certainty (rather than guessing based on file sizes)
    • For example, RUM vendors could offer insights and suggestions to enable more advanced encodings and/or dictionaries

CC @pmeenan @horo-t

@yoavweiss
Copy link
Contributor

Similar to Content-Type, this probably needs to be restricted to content that is CORS-enabled or same-origin. That's not a limitation for the dictionary compression encodings (as they have similar restrictions). This might be a limitation for non-dictionary ztd/brotli.

@nicjansma
Copy link
Contributor Author

Discussed on the Feb 29, 2024 W3C WebPerf call:

Summary:

  • General agreement this would be useful for RUM providers
  • This is similar to work that has been merged in for Content-Type (behind a flag in Chromium)
  • Chrome net team will be picking up the spec work (in Fetch and ResourceTiming) to complete this and get it into Chromium

@horo-t
Copy link
Member

horo-t commented Mar 4, 2024

Filed chromium side bug. https://crbug.com/327941462

+CC: @Jxck who is interested in this.

@Jxck
Copy link

Jxck commented Mar 14, 2024

Thanks @horo-t I'm happy to work on it !
Let me check.

Jxck added a commit to Jxck/resource-timing that referenced this issue Mar 25, 2024
add `contentEncoding` to Resource Timing.
closed w3c#381.
@guohuideng2024
Copy link

@guohuideng2024
Copy link

guohuideng2024 commented Dec 6, 2024

I plan to filter the contentEncoding value before exposing it in resource timing. ( The unfiltered value in the response header remains for other uses), but how exactly the value should be filtered?

Continuing the discussing in whatwg/fetch#1742.

Below are the possible values that are registered. I am putting them in the following categories:

-- definitely allowed (confirmed that Chromium supports in WPT tests)
br
dcb
dcz
deflate
gzip
zstd

-- maybe allowed?
compress

-- What about these? Maybe not allow? why?

exi
identity
pack200-gzip
aes128gcm

-- The below are deprecated. Since we are building new feature, should we just disallow them( forcing the app to change to the up-to-date name)? Or should be be forgiving and transfer them to compress and gzip?

x-compress Deprecated (alias for compress)
x-gzip Deprecated (alias for gzip)

-- What about these? They are not registered contendEncoding values, should we disallow them?
br-d
zstd-d

++++++++++++++++
A disallowed value will be exposed as unknown
++++++++++++++++
Thanks!

@pmeenan
Copy link

pmeenan commented Dec 6, 2024 via email

@guohuideng2024
Copy link

guohuideng2024 commented Dec 9, 2024

Based on what Patrick said above and some digging, I think the following could be filtered out:

aes128gcm: looks like this is only used for "pushing messages", not for receiving resources via fetch
compress, exi, pack200-gzip: not supported in chromium
br-d, zstd-d, x-compress and x-zip: they are deprecated name
identity: it's just a reserved name

And the following will be supported:
br, dcb, dcz, deflate, gzip, zstd

(last updated 2024/12/11)

@nhelfman
Copy link

nhelfman commented Dec 15, 2024

I think we must also specify what would be the value in case there is no content encoding (i.e. uncompressed payload).
It should be differentiated from the unknown case so we can track these separately. An example use case is when a CDN process decides to no compress the payload due to some issue (a real scenario I had). It is important to being able to identify these cases.

Seems easiest to just not set the value in that case so that when the property is read it will be JS undefined. However, this will harm supportability discovery since it will not be possible to determine if there was no encoding or the feature is not supported / or allowed by the UA.

My suggestion is for a specific string value in that case:
undefined / uncompressed / no-encoding

Anyone has a preference or other suggestions?

@yoavweiss
Copy link
Contributor

yoavweiss commented Dec 15, 2024

"identity" seems appropriate IMO.

@guohuideng2024
Copy link

guohuideng2024 commented Dec 16, 2024

Thanks for pointing out the "identity" value meaning Yoav. I missed it. :)

And I think I could mention the "identity" value too in the fetch standard modification.
I am going to modify the CLs and PRs accordingly, and I will soon start reviewing process after that.

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

Successfully merging a pull request may close this issue.

7 participants