Score:1

Cloudflare uncompressing, then re-compressing response bodies

pf flag

I'm using Node.js/express and if I set the headers

Content-Type: application/json
Content-Encoding: gzip

and send gzipped compressed bodies of JSON data, this works as expected - when not behind Cloudflare.

But if behind Cloudflare and with Brotli compression enabled in the settings, Cloudflare unpacks my gzipped data and sends it to the client compressed it as brotli.

The Cloudflare documentation claims that encoding headers are respected and compression is avoided in in case of gzip or other compression.

Of course, Cache-Control: no-transform "fixes" the issue. But why should this be needed? Is this a Cloudflare bug or am I doing something wrong?

Score:1
cn flag

From the docs:

Cloudflare will return brotli-reencoded responses to compatible clients / browsers for the following content-types:

text/html
text/richtext
text/plain
text/css
text/x-script
text/x-component
text/x-java-source
text/x-markdown
application/javascript
application/x-javascript
text/javascript
text/js
image/x-icon
image/vnd.microsoft.icon
application/x-perl
application/x-httpd-cgi
text/xml
application/xml
application/xml+rss
application/vnd.api+json 
application/x-protobuf 
application/json
multipart/bag
multipart/mixed
application/xhtml+xml
font/ttf
font/otf
font/x-woff
image/svg+xml
application/vnd.ms-fontobject
application/ttf
application/x-ttf
application/otf
application/x-otf
application/truetype
application/opentype
application/x-opentype
application/font-woff
application/eot
application/font
application/font-sfnt
application/wasm
application/javascript-binast 
application/manifest+json 
application/ld+json
application/graphql+json
application/geo+json

If you do not want a particular response from your origin to be (re-)encoded, you have to disable this by setting the cache-control: no-transform header.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.