Prefix Caching
An LLM inference optimization technique that caches and reuses the KV Cache from requests sharing identical prefixes, thereby reducing redundant computation and improving processing efficiency for multi-turn conversations and batches of similar requests.
Core Facts
The KV Cache mechanism can cache repeated prefix content, and the more concise the system prompt, the higher the cache hit rate.
Prompt caching saves the KV state of reusable prefixes (the tokens at the beginning of a prompt that remain unchanged); if the next request starts with an identical prefix, the provider reuses the saved computation and only processes the new portion.
Prefix caching improves inference efficiency by caching common prompt prefixes to reduce redundant computation.
Timeline (last 90 days)
The approach of saving states on a coarse-grained grid wastes a large amount of reusable prefix, and the portions between checkpoints can only be recomputed.
Cold resend limits the room for sustainable discounts, so discounts should be tied to cache state rather than promised unconditionally.
At a context length of 65,536 tokens, cache hits reduced the computational cost of repeated prefixes by more than two orders of magnitude.
The research team uses trajectory structure for trajectory-aware routing and scheduling to simultaneously promote prefix cache reuse and balance worker loads.
Prefix caching only takes effect on parts that are identical from the very beginning, so stable formatting of the system prompt is a prerequisite for its effectiveness.
After enabling aggressive prefix caching and state reuse, the time to first token on private inference nodes dropped from 1200ms on the cloud to under 340ms locally, with a cache hit rate above 90%.
DeepSeek Harness's design notes call prefix cache hits "Corollary No. 1," i.e., it is a byproduct of the accounting rules rather than a specifically optimized goal.
DeepSeek's caching mechanism is prefix caching: the server hashes the input token sequence of each request by prefix, and if the start of the current request exactly matches a previous request, the KV cache for that prefix can be reused directly.
The key constraint of prefix caching is that the prefix must match token by token; even inserting a single character earlier in the text invalidates everything from that position onward.
Standard prefix caching keeps historical visual tokens in a persistent KV cache whose capacity grows linearly with the number of interaction rounds, quickly exhausting the limited memory budget.
37 more timeline events
All Facts (20)
The KV Cache mechanism can cache repeated prefix content, and the more concise the system prompt, the higher the cache hit rate.
90%VerifiedPrompt caching saves the KV state of reusable prefixes (the tokens at the beginning of a prompt that remain unchanged); if the next request starts with an identical prefix, the provider reuses the saved computation and only processes the new portion.
80%VerifiedPrefix caching improves inference efficiency by caching common prompt prefixes to reduce redundant computation.
75%VerifiedCaching means pre-storing recurring system prompts or long documents so that subsequent requests reuse them at a lower unit price, suitable for multi-turn Q&A or fixed knowledge base scenarios.
65%VerifiedPrompt cache validity typically ranges from only a few minutes to several hours, and discount rates and cache windows may be adjusted at any time.
65%UnverifiedWhen a prefix cache hit occurs, inference latency can drop from the second level to the millisecond level, and the cache-hit price offered by various vendors is typically one-tenth or even lower than the cache-miss price.
70%UnverifiedAfter using the KV cache, single-token latency remains essentially flat and no longer grows significantly with context length, indicating that the bottleneck is no longer matrix multiplication but fixed overheads such as CPU-side scheduling, kernel launch overhead or GPU memory bandwidth.
60%UnverifiedA prompt cache hit requires the request prefix to be byte-for-byte identical to what was written at cache time; mixing dynamic content such as timestamps or session IDs into system prompts will cause frequent cache invalidation.
60%UnverifiedPrefix caching is extremely sensitive to input stability; as long as any single token in the prefix is modified or inserted, the cache is invalidated and all subsequent content must be recomputed.
60%UnverifiedMainstream inference frameworks such as vLLM already natively support automatic prefix caching.
60%UnverifiedThe approach of saving states on a coarse-grained grid wastes a large amount of reusable prefix, and the portions between checkpoints can only be recomputed.
50%UnverifiedCold resend limits the room for sustainable discounts, so discounts should be tied to cache state rather than promised unconditionally.
50%UnverifiedAt a context length of 65,536 tokens, cache hits reduced the computational cost of repeated prefixes by more than two orders of magnitude.
50%UnverifiedThe research team uses trajectory structure for trajectory-aware routing and scheduling to simultaneously promote prefix cache reuse and balance worker loads.
50%UnverifiedPrefix caching only takes effect on parts that are identical from the very beginning, so stable formatting of the system prompt is a prerequisite for its effectiveness.
50%UnverifiedAfter enabling aggressive prefix caching and state reuse, the time to first token on private inference nodes dropped from 1200ms on the cloud to under 340ms locally, with a cache hit rate above 90%.
50%UnverifiedDeepSeek Harness's design notes call prefix cache hits "Corollary No. 1," i.e., it is a byproduct of the accounting rules rather than a specifically optimized goal.
50%UnverifiedDeepSeek's caching mechanism is prefix caching: the server hashes the input token sequence of each request by prefix, and if the start of the current request exactly matches a previous request, the KV cache for that prefix can be reused directly.
50%UnverifiedThe key constraint of prefix caching is that the prefix must match token by token; even inserting a single character earlier in the text invalidates everything from that position onward.
50%UnverifiedStandard prefix caching keeps historical visual tokens in a persistent KV cache whose capacity grows linearly with the number of interaction rounds, quickly exhausting the limited memory budget.
50%