Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloudrun omits content-encoding: zstd

Hello,

I wanted to bring to your attention that the latest version of Google Chrome has enabled `zstd` by default. However, we have noticed that the responses from our backend, which is hosted on Cloud Run, are not working as expected. Upon further investigation, we discovered that the `content-encoding` is being omitted from the response when `zstd` is set to accept-encoding in the request. 

curl <url> -H 'accept-encoding: gzip,deflate,br,zstd' -i 

HTTP/2 200 
content-type: text/html; charset=utf-8
vary: Accept-Encoding, Accept-Language, Cookie, origin
content-language: th-th
x-frame-options: SAMEORIGIN
strict-transport-security: max-age=60; includeSubDomains
x-content-type-options: nosniff
referrer-policy: same-origin
cross-origin-opener-policy: same-origin
set-cookie: csrftoken=8Q2LzaIZQCil0OhbNd3ccBNfb4kNjrqT; expires=Thu, 20 Feb 2025 04:51:25 GMT; Max-Age=31449600; Path=/; SameSite=Lax
x-cloud-trace-context: 19caa61de33342e785793de2df1aab56
date: Thu, 22 Feb 2024 04:51:25 GMT
server: Google Frontend
content-length: 4106
expires: Thu, 22 Feb 2024 04:51:25 GMT
cache-control: private
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

However, it works normally if we remove `zstd` from the `accept-encoding` header.

curl <url> -H 'accept-encoding: gzip,deflate,br' -i

HTTP/2 200 
content-type: text/html; charset=utf-8
vary: Accept-Encoding, Accept-Language, Cookie, origin
content-language: th-th
x-frame-options: SAMEORIGIN
strict-transport-security: max-age=60; includeSubDomains
x-content-type-options: nosniff
referrer-policy: same-origin
cross-origin-opener-policy: same-origin
set-cookie: csrftoken=URmkfnDknLkmI0Q4hrNUTwTMTuIQyOXI; expires=Thu, 20 Feb 2025 04:53:35 GMT; Max-Age=31449600; Path=/; SameSite=Lax
content-encoding: br
x-cloud-trace-context: c2778673e2254dd8e5d56bbb097d7385
date: Thu, 22 Feb 2024 04:53:35 GMT
server: Google Frontend
content-length: 4008
expires: Thu, 22 Feb 2024 04:53:35 GMT
cache-control: private
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

We found that the `zstd` encoded content was returned from our backend and can be decoded, but the `content-encoding` is missing.

curl <url> -H 'accept-encoding: zstd' --output - | unzstd

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
...

We would like to know how we can fix this issue.

Please help.

2 1 829
1 REPLY 1

Hi @napat,

Welcome to Google Cloud Community!

Cloud Run isn't setting the content-encoding: zstd header when Chrome requests it.

These might help you:

  • Update your backend application: Check if your framework handles content encoding automatically.
    If not, manually set the content-encoding header based on the request.
  • Use Cloud Functions: They automatically handle content encoding, including zstd.
  • Explore Cloud Run settings (experimental): Look for "Content Encoding" in the service's "Settings" tab.
Top Solution Authors