Zenaique
Compare

Prompt caching vs KV caching

Two ways to stop paying for the same tokens twice

The verdict

KV cache reuses attention within a single generation; prompt caching reuses that cache across separate requests that share a prefix. Both attack the same waste from different angles.

KV cache

Glossary

During autoregressive generation, the model caches the key and value tensors it already computed for prior tokens so it does not recompute them for each next-token step. Built into every transformer inference stack.

Best for: Every single LLM generation, always.

Prompt caching

Glossary

A provider feature (Anthropic, OpenAI, Google) that stores the KV cache for a stable prompt prefix and reuses it across separate requests. Cached input tokens bill at a large discount (usually 50 to 90 percent) and first-token latency drops.

Best for: Long stable system prompts reused across many calls.

At a glance

Prompt caching vs KV caching: dimension-by-dimension comparison
DimensionKV cachePrompt caching
ScopeWithin one generationAcross separate requests
Where it livesIn the inference processProvider or shared server
Requires code changeNo (built in)Yes (mark the cacheable prefix)
First-token latencySmall, per tokenDrops sharply on cache hit
Cost impactCompute onlyCompute plus input-token discount (50-90%)
Best forEvery LLM callLong stable prefixes (system prompt, tool defs)

Key differences

  • 1KV cache lives inside one generation; prompt caching lives across many requests
  • 2KV cache is universal in transformer inference; prompt caching is a provider (or serving-framework) feature
  • 3KV cache never sees the network; prompt caching hands the cache to the provider or a shared server
  • 4KV cache saves compute; prompt caching saves both compute and input-token bill
  • 5You always benefit from KV cache; you only benefit from prompt caching when a prefix is stable across requests

In the interview

What they're really testing
Whether you can distinguish generation-time caching from request-time caching, and know when the provider feature actually pays.
Say this
The KV cache is built into transformer inference: during autoregressive generation the model reuses the key and value tensors from prior tokens rather than recomputing them. Prompt caching is a provider feature (Anthropic, OpenAI, Google) that stores that KV state across separate requests when the prompt prefix is stable, so a repeated system prompt or tool definition block bills at a large discount and returns the first token faster. I always rely on the KV cache; I enable prompt caching when more than three quarters of the input tokens are a stable prefix.
Traps to sidestep
  • Conflating KV cache with prompt caching
  • Claiming prompt caching makes prompts free (input tokens are discounted, not zero)
  • Ignoring the provider-side prefix invalidation rules (any change busts the cache)
  • Missing that shared serving frameworks (vLLM, TGI) can implement similar prefix reuse locally

How to choose

If any LLM generationKV cache
If long stable system prompt reused across many requestsPrompt caching
If prompt prefix changes every requestKV cache
If you host your own inference and want cross-request reusePrompt caching

Always use the KV cache. Turn on prompt caching when the shared prefix is a big fraction of the input.

Common misconceptions

Myth: Prompt caching removes the need for cheap prompts.

Reality: Cached input tokens still bill, just at a large discount. A long stable system prompt with prompt caching is still worth trimming.

Myth: KV cache saves cost across users.

Reality: Standard KV cache is per-generation only. Cross-request reuse needs a serving framework feature or the provider's prompt-caching API.

Memory aid

KV cache = remembering what you already computed for THIS answer. Prompt caching = not re-reading the same instructions every time a new question arrives.

Can you combine them?

They stack: KV cache runs inside every generation; prompt caching reuses the cache across requests with the same prefix. Together they turn a long shared system prompt from a per-request cost into a build-once, reuse-many artifact.

Related topics

Related comparisons