Have Cloudflare serve Brotli compressed static assets from Origin

My website serves a heavy payload that is much smaller when Brotli compressed than when gzipped. I’m running into a limitation where Cloudflare caches only request gzipped data from the origin (see documentation here), which the caches then decompress and compress with Brotli. It looks like the Brotli compression used by Cloudflare caches is not tuned to the maximum settings, which results in a compressed payload that is a little bigger than my own gzipped payload, so I don’t see any benefits from using Brotli compression on Cloudflare caches.

Is there anything I can do to get Cloudflare caches to serve my own Brotli compressed file? Any plans to allow Cloudflare caches to request Brotli compressed data from the origin?

Thank you!

You can always get better Gzip or Brotli compression than Cloudflare, as Cloudflare are trying to reduce the time taken to get a file to the user, rather than trying to minimize the file size.

(Have not tried this, but it should work)

Use a URL Transform Rule to append a query parameter to the Request when you detect that a user-agent supports BR (Incoming request matches (http.request.headers["accept-encoding"][0] contains "br") )

Then on your origin, when you detect the query parameter, you can just serve your BR compressed version. Probably best to append a “Cache-Control: no-transform” header onto the response.


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