The correct way to change the pages gzip/br content compression rule?

For Workes & Pages, what is the name of the domain?

gz.selfhost.sotre br.selfhost.store

What is the issue or error you’re encountering

the correct way to change the gzip/br content compression rule ?

What steps have you taken to resolve the issue?

I bind my domain to my cloudflarepages site, and use the “Compression Rules” to change the compression , the rules is : if request.full contains gz. , use gzip , if request.full contains br., use br . now i have 2 domain , gz.xxx.com and br.xxx.com, but i didnt see a bundled size reduction between those , and through webpagetest i cant see any speed improvement in br compression over gzip, is there any problems to my settings?

Hi there,

Your settings seem fine, and both subdomains show different encoding as expected:


Although Brotli offers better compression ratios than Gzip, in such a smaller scale it does not make that big of a difference, but there is indeed some size reduction if you compare them.

Let’s take “index-BEcJqCfm.css” for instance:

No compression from br. and gz. sudbomains:

❯ curl 'https://br.selfhost.store/assets/index-BEcJqCfm.css' --location --silent --write-out 'size_download=%{size_download}\n' --output /dev/null
size_download=395042
❯ curl 'https://gz.selfhost.store/assets/index-BEcJqCfm.css' --location --silent --write-out 'size_download=%{size_download}\n' --output /dev/null
size_download=395042

With gzip:

❯ curl 'https://gz.selfhost.store/assets/index-BEcJqCfm.css' --location --silent  -H 'Accept-Encoding: gzip,deflate' --write-out 'size_download=%{size_download}\n' --output /dev/null
size_download=31989

With Brotli:

❯ curl 'https://br.selfhost.store/assets/index-BEcJqCfm.css' --location --silent  -H 'Accept-Encoding: br,deflate' --write-out 'size_download=%{size_download}\n' --output /dev/null
size_download=18129

So as you can see, br does indeed compress a bit more - note that this isn’t always the case though, and there are legitimate use cases where gz might be a better choice.
Overall I prefer to leave them both enabled and let the client decide.

This was a good practical exercise to show the differences in compression though.

Take care.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.