Is It Worth Compressing Responses If Using Cloudflare?
Asked by
meter-7eight
I'm wondering if it makes sense to compress responses from my server when I'm already using Cloudflare, which also handles compression. Will compressing responses reduce the payload size between my origin server and Cloudflare enough to justify the extra processing overhead?
Answers
As far as I know, Cloudflare does compress payloads by default. You can check this in the Network DevTools section by looking at the headers of the response to see if itโs already being compressed.
Reply to this answer
If youโre serving brotli compressed responses from your origin, and you donโt enable Cloudflare settings that require examining the payload, it can pass through your compressed responses directly, which is faster. Pre-compressing your assets is generally a smart move, even if you donโt configure passthrough.
Reply to this answer
In most cases, the cost of data transfer is higher than the processing needed for compression, so there can still be a significant benefit to compress if you're transferring large amounts of data.
Reply to this answer
Generally, compressing data before it reaches Cloudflare may not provide much benefit since running the same compression algorithm twice on the same file yields minimal improvements. You might actually lose more with the additional computational overhead. Itโs worth testing on your own to see if you notice any difference, but odds are you wonโt gain much from it.
Reply to this answer
It really depends on your traffic costs. Reducing the bytes that Cloudflare requests from your origin could save you on infrastructure costs, making compression worthwhile if you're dealing with large amounts of traffic.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions