Cloudflare found a neat way to squeeze more out of their cache and save a ton of money and storage. Here’s what they did …
“compress what is already sitting there”, and it is called Cache Transcoding. The idea is simple…
When a response enters the cache, their proxy encodes the body with Zstandard before writing it to disk. It stays compressed the whole time it is cached and moving between data centers, and only gets decoded right before it hits the client.
Not everything gets this treatment.
Given that the images and video are compressed already, so recompressing them is wasted CPU. Hence, they focus on compressing texts - html, css, json, js, etc.
This compression resultes in a 2.8x reduction with zstd level 3.
This tradeoff makes sense because assets get read far more often than they get written and hence they prefer to pay a small decode cost repeatedly.
Compress once, decode cheap that is the whole idea.