Skip to content
Engineering

Cloudflare's Cache Transcoding: Boosting Cache with Zstandard Compression

Cloudflare tests Cache Transcoding with Zstandard compression to expand cache capacity, impacting storage and bandwidth efficiency.

Topic
Engineering
Reading time
5 min
Length
1,013 words
Published
Sep 13, 2026
11:20 pm IST
In this article
  1. Understanding Cache Transcoding
  2. Key Benefits and Considerations
  3. Practical Steps for Implementing Cache Transcoding
  4. Limitations and Considerations

Cloudflare recently described a prototype called Cache Transcoding that uses Zstandard compression to boost cache storage capacity. This method focuses on uncompressed text content like HTML, JSON, CSS, and JavaScript, compressing it before storage to enhance the cache capacity. The hyperscaler estimates that the approach could provide petabytes of additional effective cache capacity, although broader testing is still needed. More testing is needed to see how this pans out across different scenarios.

Understanding Cache Transcoding

Cache Transcoding is all about squeezing more out of storage by compressing text files before stashing them in the cache. Cloudflare says this mainly targets uncompressed text, which is a big chunk of web traffic. Once compressed, the content takes up less space and reduces data transfer between data centers—saving both storage and bandwidth.

Key to this whole process is Zstandard, a lossless compression algorithm from Facebook, known for its knack for real-time compression. Zstandard works without causing delays, which is a big plus. When paired with Pingora, Cloudflare's Rust-based proxy framework, it handles compression with only a small bump in CPU usage. This way, Cloudflare gets maximum effective cache capacity. The cost of encoding hits just once when content enters the cache, ensuring the savings in storage and bandwidth kick in every time that content gets reused.

Aashi Patel from Cloudflare summed it up nicely: "A small increase in CPU gives Cloudflare petabytes of effective cache capacity and reduces the data transferred between our data centers. The encoding cost is paid once when an asset enters the cache. The storage and bandwidth savings continue every single time that asset is reused."

Key Benefits and Considerations

Cache Transcoding comes with some hefty perks. By compressing content about 2.8 times, Cloudflare can pack more data onto existing servers, optimizing resource use. Plus, this compression cuts down on the amount of data zipping between data centers, which could lead to cost savings and better performance across distributed systems.

But Cache Transcoding isn't a magic bullet. It only works on uncompressed responses with compressible text that return successfully and are at least 4 KiB in size. This threshold is deliberate to dodge the overhead of handling a bunch of small objects while leaving only about 1% of eligible data unoptimized. Also, the Zstandard compression level and what counts as eligible content can be tweaked to juggle CPU usage with storage needs for specific scenarios.

Remember, stuff like images, video, and fonts usually come pre-compressed. Trying to compress them again often won't give any extra benefits and might even hog more CPU. In Cloudflare's traffic sample, media content made up 21.4% of requests but accounted for 63.3% of bytes, showing it's not worth it to try compressing that data further. The real target is compressible text content, which was 67.3% of requests and 22.3% of bytes, with 71% of it uncompressed and ripe for effective compression.

Practical Steps for Implementing Cache Transcoding

If you're managing production environments, implementing Cache Transcoding could mean serious gains in cache efficiency and slashed data transfer costs. Here's how you might approach it:

  • Evaluate Data Types: Take a good look at the types of data your app handles to see if compression will help. Zero in on uncompressed text content that can shrink well with Zstandard. Understand your data's specific traits and how they fit the compression criteria to get the most out of it.
  • Adjust Compression Settings: Play around with different Zstandard compression levels to find that sweet spot between CPU use and storage savings. The size threshold also needs careful consideration to avoid wasting resources on tiny objects. Start with a moderate compression level and tweak it by watching performance metrics. That's worked for me, anyway.
  • Monitor and Test: Test thoroughly to see how this impacts cache performance and bandwidth. Use tools to mimic different cache situations and gauge transcoding's impact on your infrastructure. Regular checks can spot any bottlenecks or issues with the new compression strategy.
  • Plan for Scalability: Think about how that extra cache capacity can help your app grow. This could be a chance to optimize resources and plan for scaling without major infrastructure overhauls. Look at your long-term data growth trends and align them with the new cache capabilities for strategic advantages.

Limitations and Considerations

While Cache Transcoding has its benefits, it's not all sunshine and rainbows. Not every kind of content benefits from compression, and there are cases where the CPU cost might overshadow storage gains. For instance, range requests can be tricky. These let clients ask for specific parts of a file, and without compression, these requests are easy to handle by just reading that section. But in a compressed setup, serving the correct data requires some extra processing since compression changes how the data is stored.

The prototype's still a work in progress, and Cloudflare plans to test further with various compression levels, content types, sizes, and cache scenarios. Staying updated on these developments and best practices as they evolve is essential. There's some debate about the term "transcoding" because it involves encoding and decoding, not transforming content formats, which is something to keep in mind. Understanding the mechanics of this process and being ready for potential challenges during implementation is important.

Moreover, compressing only uncompressed text content that's at least 4 KiB is a strategic choice. This avoids the inefficiencies of processing loads of small objects, which could suck up more CPU resources than the savings justify. However, it also means about 1% of potentially compressible data is left unoptimized. For applications where even small efficiency gains matter, this is something to keep in mind.

Another thing to watch is the potential impact on response times, especially for cache misses where decompression is needed before serving data. While the benefits for storage and bandwidth are clear, that extra decompression step can introduce slight latency, potentially significant for latency-sensitive apps. Monitoring and adjusting compression settings is wise to keep performance within acceptable limits. Balancing these trade-offs requires a detailed understanding of your application's needs and the typical data access and modification patterns. That's been my experience, at least.

Sources

Cloudflare Tests Cache Transcoding to Reduce Storage Requirements

Every claim above was checked against this source before publishing. The analysis, the code and the opinions are mine.

Frequently asked

What is Cloudflare's Cache Transcoding?

Cache Transcoding is a prototype by Cloudflare that uses Zstandard compression to compress eligible text content before storing it in cache, thereby increasing effective cache capacity and reducing data transfer.

What types of content does Cache Transcoding target?

It targets uncompressed text such as HTML, JSON, CSS, and JavaScript that are at least 4 KiB in size, excluding already compressed, binary, or unknown-sized content.

What are the benefits of using Cache Transcoding?

The main benefits include increased cache storage capacity, reduced data transfer between data centers, and optimization of server resource usage.

What are the limitations of Cache Transcoding?

It may not be beneficial for already compressed content like images and videos, and handling range requests could present challenges.

Deepak Kumar

Written by

Deepak Kumar

Sr Software Engineer at India Today Group | Aaj Tak · MERN Stack · Generative AI

I build production web applications and Generative AI systems, and I have spent most of nine years on the maintenance end of other people's architectural decisions. I write here about what those systems actually do once real traffic hits them.

Message me