Skip to main content
PromptQuorumBuilt for humans. Structured for AI.

What Is Prompt Caching for Local LLMs?

By · Founder of PromptQuorum · Discovery engine for open-weight & open-source AI

Prompt caching stores the intermediate computation (the KV cache) for a prompt's prefix so a repeated or extended prompt doesn't have to reprocess that prefix from scratch. It speeds up any workload where requests share a common beginning — a fixed system prompt, a long document reused across questions, or the earlier turns of an ongoing conversation — but does nothing for requests with no shared content.

Key Takeaways

  • ✓Prompt caching stores the KV cache computed for a prompt's prefix, letting a later request reuse it instead of reprocessing the same tokens
  • ✓The bigger and more repeated the shared prefix, the bigger the speedup — a long, unchanging system prompt reused across thousands of requests benefits enormously
  • ✓Multi-turn conversations benefit automatically in most local serving setups, since each new turn shares the entire prior conversation as its prefix
  • ✓Caching only helps prompt processing (the input), not token generation (the output) — it reduces time-to-first-token, not tokens-per-second once generation starts
  • ✓Prompt caching and prefix caching mean reusing the KV cache across separate requests; the KV cache itself already exists inside every single generation
What Is Prompt Caching for Local LLMs?

Quick Answer

Prompt caching stores the computed key-value (KV) cache for a prompt's prefix so it doesn't need to be recomputed when a later request shares that same prefix — a fixed system prompt, a reused document, or earlier conversation turns. It cuts prompt-processing time significantly for repeated-prefix workloads, but provides no benefit when every request is unrelated.

  • ▸Caches the KV cache for a prompt prefix, not the model's output
  • ▸Biggest win: long fixed system prompts, reused documents, multi-turn conversations
  • ▸No benefit for one-off requests with no shared prefix across calls
Technique & Concept ExplainersIntermediate

How Caching Actually Speeds Things Up

Processing a prompt means the model computes a key-value (KV) representation for every input token before it can start generating a response. This step — prompt processing — happens before generation begins, and its cost scales with prompt length. Without caching, a 2,000-token system prompt gets fully reprocessed on every single request, even if it's byte-for-byte identical each time.

Caching stores that computed KV representation for a given prefix, keyed to the exact token sequence. When a new request starts with the same tokens, the cached KV values are reused directly, and only the new, non-cached portion of the prompt needs processing. The practical effect is that time-to-first-token drops sharply for cache hits, since most of the input no longer needs recomputation.

This is why multi-turn conversations benefit almost automatically: turn 3 of a conversation includes turns 1 and 2 as its prefix, so a caching-aware serving setup only processes the newly added turn, not the entire conversation history over again.

Prompt Caching, Prefix Caching and KV Caching: How They Differ

Prompt caching, prefix caching and KV caching are related but not the same thing. The KV cache is the data structure: the key and value tensors a model computes for each token, which it keeps during generation so earlier tokens are not recomputed at every step. Every transformer inference engine has one, and it exists within a single request.

Prefix caching and prompt caching both mean keeping that KV data and reusing it across separate requests. "Prefix caching" names the mechanism (matching a shared token prefix); "prompt caching" is the broader, user-facing term. vLLM calls its implementation automatic prefix caching: it caches the KV cache of earlier queries so a new query with the same prefix skips that computation. The llama.cpp server exposes the same idea as a per-request cache_prompt option, enabled by default, so only the part of the prompt that differs is processed.

In short: KV caching happens inside every generation, while prompt or prefix caching carries the KV cache from one request to the next and depends on your serving tool and on an exact-match prefix. If you use a desktop app such as LM Studio, check that app's own documentation to see whether and how it exposes the setting.

Structuring Prompts to Actually Benefit

  • ▸Put shared, unchanging content first. System prompts, instructions, and reference documents that stay identical across requests should come before the variable, request-specific content — caching only works on an exact-match prefix, so anything before the first point of difference is what gets reused.
  • ▸Keep the shared prefix byte-identical across requests. Even a single-character difference in a system prompt (a timestamp, a random ID) breaks the prefix match and forces full reprocessing — move any per-request variation to the end of the prompt, after the reusable content.
  • ▸Don't expect caching to help unrelated, one-off requests. If your workload is mostly single-shot questions with no shared setup, there's nothing for caching to reuse — the technique's value is proportional to how much of your traffic actually shares a common prefix.
  • ▸Long-running conversations benefit most from cache retention settings. Check how long your serving setup keeps cached prefixes before evicting them — a cache that's evicted too aggressively won't help conversations with gaps between turns.

Frequently Asked Questions

Does prompt caching change the model's output?▾
In principle no — caching reuses the same computed KV values instead of recomputing them, so it changes speed, not model behavior or quality. In practice the llama.cpp server documentation notes that results are not guaranteed to be bit-for-bit identical across different batch sizes, so tiny numerical differences between a cached and an uncached run are possible.
Does prompt caching help token generation speed, or just the initial response time?▾
Only the initial response time (time-to-first-token). Once generation starts, tokens are still produced one at a time at the same generation speed regardless of caching — caching eliminates redundant prompt-processing work, not the generation step itself.
How much VRAM does caching use?▾
Cached KV data lives in VRAM alongside the model itself, and its size scales with how much context is being cached and for how many concurrent conversations. Caching many long conversations simultaneously can meaningfully add to VRAM usage — this is a real tradeoff against caching depth on VRAM-constrained hardware.
Does every local serving tool support prompt caching?▾
Support and default behavior vary by tool — some cache automatically for multi-turn use within a session, others require explicit configuration, and cache retention (how long a prefix stays cached before eviction) is also tool-specific. Check your specific serving tool's documentation for its caching behavior and any settings that control it.
Is prompt caching the same as KV caching?▾
No. The KV cache is the per-token key and value data a model keeps while generating, and it exists in every request. Prompt caching (also called prefix caching) is the reuse of that KV data across separate requests that share the same beginning, so the shared part is not computed again.
What is prefix caching?▾
Prefix caching is the mechanism behind prompt caching: the serving engine stores the KV cache for a sequence of tokens and, when a new request starts with exactly the same tokens, reuses it and processes only the remaining suffix. It requires an exact token-for-token match from the start of the prompt, and it speeds up prompt processing only, not token generation.
MCP