Gzip from origin, Brotli from edge

Is there any overhead when serving gzipped content from the origin while Cloudflare is set to use Brotli?

Hi @ney,

Serving gzipped content will force Cloudflare to decompress the file before compressing it with Brotli, and decompressing files does take processing and time. But the alternative would be to serve content uncompressed, which results in larger files that take longer to transfer.

The Cloudflare Blog has a post on Brotli compression that gives detailed information on tests they performed some time ago to evaluate the adoption of Brotli (since then, Brotli was adopted, so the mixed results shown here must have improved in further tests). From that post, I quote:

There is a tradeoff between compression speed and transfer speed. It is only beneficial to increase your compression ratio if you can reduce the number of bytes you have to transfer faster than you would actually transfer them.

It’s very hard to be certain about the potential overhead caused by serving gzipped content, since it depends on so many factors, including network conditions, caching, file size etc. But once Cloudflare fetches the content from your origin, it will serve it presumably many times from its cache, so whatever impact would only affect uncached pages or files.

If you need to know for sure, I’d suggest you set up a few test pages, with and without Gzip, set them via page rules to bypass cache (for them and any requested files), monitor them for a couple days, then compare results.

1 Like

Here’s what support answered:

Cloudflare’s request to the origin will always request for gzip content. In this case, brotli content should never be delivered to Cloudflare. This is because we frequently need to decompress and apply optimizations before we return resources to visitors. It’s more expensive to unencode brotli vs gzip, so we have no plans to change this behavior currently.

If you do not want a particular response from your origin to be encoded, you can disable this by setting cache-control: no-transform at your origin and turning Origin Cache-Control -> On using a Page Rule.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.