Prompt caching, more precisely prefix caching, works by storing the key-value tensors a model computes during prefill and reusing them when a new request begins with the same token sequence. The engine finds the longest cached prefix that matches the new request from the beginning, loads those states, and runs prefill only for the remaining tokens (Modular's inference handbook). The benefit is real but narrow: it reduces time to first token and the cost of input tokens, while output generation speed is unchanged (Michael Hannecke's overview).
Two properties of that mechanism govern every design decision in this guide.
First, matching is exact. Modular's docs give a concrete triplet: "Summarize this incident report in one paragraph" and "Summarize this incident report in three bullet points" share a cacheable prefix, because the second can reuse everything up to "Summarize this incident report in." A third prompt, "Write a one-paragraph summary of this incident report," means the same thing but shares no opening token sequence, so it misses entirely (Modular). This is why prefix caching is not semantic caching: two prompts can be synonymous and still miss, while two prompts with completely different final questions can share almost all their computation.
Second, matching operates on blocks. vLLM hashes each KV cache block using the block's tokens plus the hash of the parent block, forming a chain in which each block's identity depends on every token before it (vLLM's prefix caching design doc). Only full blocks are cached. In practice, that means a divergence early in the prompt invalidates every block after it, and a change in the last few tokens of an otherwise identical prompt may not even reach block granularity worth caching.
The practical consequence: think of your prompt as a chain rather than a document. Every token you place early is a commitment that everything downstream must share.



