Can Brotli compression be turned off on certain pages?

Is there a way to turn off Brotli compression on specific pages?

According to what will cloudflare compress, I can turn off compression by setting the server header “cache-control: no-transform”. However, I don’t have access to the server, so I can’t set up that header.

Is there anyother mean? like setting an HTML head meta header for this purspose? Or maybe any CF rule? I have explored the available rules in CF and can’t seem to find any that allows to disable Brotli compression.

I have Brotli enabled by default, which works well with cached content. If my understanding is correct, resources are first compressed and then cached, not the other way around. However, on dynamic pages that can’t be cached and are served on gzip, I believe the brotli compression gains are outweighted by the fact the CF server will recieve gzip content, uncompress and recompress it to Brotli, thus taking a longer server response time than merely serving the original gzip. Well this is what I want to test out.

That’s the link

You will need to do it at the origin server or you may be able to modify the request headers with workers.

Check this out:

Hi dmartin. Thanks for the suggestion. Doing it at origin is out of my hands. The workers option seems viable. Anyway, I ended up discovering that Cloudflare allows to set transform rules than can change http request headers. For some reason it did’t allow me to change the specific “cache-control” header I wanted to.

As a workaround, I was able to change another header, the default “accept-encoding:gzip, deflate, br” to “accept-encoding:gzip” to force gzip only and avoid brotli. This way I managed to serve some pages in gzip and do tests.

1 Like

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