KV Cache Is the Browser Cache for LLMs — and Prompt Caching Is the CDN
KV Cache is the single biggest reason LLM inference is fast enough to ship, and Prompt Caching is the single biggest lever for making it cheap enough to scale. A service that gets either wrong burns GPU memory on redundant computation, and at high concurrency the KV Cache alone can outgrow the model weights by 4×.
Every token an LLM generates would normally require recomputing attention over the entire sequence. KV Cache sidesteps that by keeping the Key and Value vectors of all processed tokens in memory, so each new decode step only computes attention for the newest token. The technique turns a cubic-cost problem into a linear one and is the reason autoregressive generation is practical at all. Without it, a 32-batch, 32k-context Qwen2.5-7B run would be impossible; with it, the KV Cache alone can still balloon to 57 GB — four times the model weights — which is why memory management matters as much as the math.
PagedAttention solves the resulting fragmentation by borrowing virtual-memory ideas: KV state is stored in fixed-size blocks, allocated on demand, and shared across requests that share a prefix. That block-level sharing is the foundation for Prompt Caching, where a long system prompt or tool definition is prefilled once and reused across every API call that starts with the same bytes. OpenAI and Anthropic both ship versions of this, with automatic prefix detection or explicit cache-control markers, and report up to 90% reductions in input cost and 85% drops in time-to-first-token.
The two layers form a complete caching stack: KV Cache makes a single generation fast, and Prompt Caching makes repeated generations cheap. The distinction is easy to miss because both store K and V vectors, but one operates inside a request and the other across requests. The Query vector is never cached — causal masking means a past Q is never queried again, so storing it would waste VRAM with no read path.
The KV Cache size scales with the product of batch size and sequence length, not with model size alone, which means concurrency is the real memory killer — not context length by itself.
Calling the technique 'KV Cache' obscures that it is really two distinct caches stacked: an intra-request compute cache and an inter-request prefix cache, each with different eviction policies and cost models.
PagedAttention is a direct lift from OS virtual memory, and the analogy holds all the way down: block tables, on-demand allocation, and external fragmentation are the same problems operating systems solved decades ago.
OpenAI's automatic prefix caching and Anthropic's explicit cache_control represent two philosophies — invisible infrastructure vs. developer-controlled cost knobs — and the tradeoff is between ease of use and predictability of billing.