IT Essentials
Caching Range Requests: Why It's Hard and How Cloudflare Did It with Chunks
An explainer on why caching HTTP Range requests naively inflates origin traffic and latency, and how Cloudflare solved it with fixed-size cache chunks and response coordination. A durable infrastructure case study for teams handling large-file delivery and cache design.
Large files travel in pieces
When a video player seeks to the middle of a movie or a download resumes after an interruption, the client asks for a byte range rather than the whole file. A GET request carrying a Range header gets back 206 Partial Content with a Content-Range header identifying exactly which bytes were sent. Video seeking, resumable downloads, package managers, and transfers of large model files all depend on this. The client decides whether to ask for a range; the hard design question is how a cache satisfies that request.
The fixed-size slicing dilemma
Cloudflare’s blog post on Origin Range Requests (October 2026) is a good case study of this problem. Their earlier implementation resembled nginx-style cache slicing: files were divided into fixed-size ranges, with the size configured per zone. The setting created a dilemma. Small ranges meant a stream of tiny origin requests and memory pressure from coalescing them; large ranges meant pulling far more data than the client asked for. R2, Cloudflare’s object storage and their largest internal user, used 64 MiB ranges, so a small read that crossed a boundary could trigger 128 MiB of transfer between data centers, and the waste multiplied across cache tiers. Because the range size was part of the cache key, changing it invalidated cached entries, and concurrent requests falling inside the same range could block each other.
Cache chunks as the range unit
The new implementation starts from something the Pingora-based cache already did: every cached file is stored on disk in fixed-size chunks, originally to support resumable downloads. If the cache already thinks in chunks, the range size doesn’t need to be a setting at all. Cached bytes are read directly; missing bytes are fetched from the origin as chunk-aligned ranges, stored in the same chunks, and only the requested bytes go back to the client. Cloudflare describes the result as “coordinator, not a single cache lookup”: one response can be assembled from a cached prefix, a download already in flight, and a newly fetched suffix, and a second request can attach to an in-flight download instead of starting another origin fetch. Correctness checks guard the composition: the origin response must match the requested range, the total asset size must stay stable, and the entity tag must be consistent across subrequests. If an If-Range validator no longer matches, the full representation is served rather than bytes from mixed versions, and responses about to be decompressed are not composed, since a range over compressed bytes differs from one over the decompressed body. Outward behavior stays standard HTTP: 206 for a satisfiable range, 416 for an unsatisfiable one, and the full representation whenever ranging would be unsafe.
What it bought, and what it teaches
According to Cloudflare’s own measurements, R2’s p99 time to first byte dropped by roughly half on both cache hits and misses, and a later change that let the coordinator combine bytes from disk with bytes fetched upstream cut tiered-cache traffic for R2-like workloads by about 6% week over week — petabytes less moving between their data centers daily. The durable lesson is architectural: replace an operator-tuned parameter with a bounded, predictable internal invariant. Any team building proxies or storage for large objects faces the same tradeoff, and chunk-based range coverage with request coalescing is one well-tested answer. The limits are equally instructive: requests smaller than a chunk can still fetch a whole chunk, enabling it is down to a Cache Rule and doesn’t change what is cacheable in the first place, and it only helps when the origin itself supports byte ranges. Cloudflare also says it intends to make this the default way certain file types are served.