short · 3 min
Semantic caching
Reusing a past answer when a new question means the same thing.
updated 29 Sept 2026
Start with a rule that sounds obviously right: if two questions mean the same thing, they should get the same answer.
"What's your return policy?" and "How do I return an item?" A help desk would answer both the same way. So if our support bot already answered the first, why pay the model to answer the second? Hand back the stored answer in tens of milliseconds, for no tokens at all. That's a semantic cache.
An ordinary cache can't do this. It looks up the exact text, and those are different strings. So instead the cache runs a small semantic search over questions it has seen before:
We turn the question into an embedding, find the nearest past question (usually by cosine similarity), and return its answer if it's close enough. Otherwise the model answers and we store the new pair, with an expiry time.
Unlike RAG, this stores whole answers, not chunks. It's also different from prompt caching, even though the names get mixed up. Prompt caching reuses the provider's work on a repeated start of the prompt, but the model still runs and writes every token. A semantic cache hit skips the model, so it saves more, and it can also be wrong in a way prompt caching never is.
Where the rule breaks
"Closer than some threshold." That's where all the trouble is.
Too loose and we serve answers to questions that were only similar. Too tight and almost nothing hits. People tend to pick a number like 0.8 and move on.
The problem is that closeness in embedding space doesn't line up neatly with "same answer". Two questions can sit very close and still need different answers, and two others can sit further apart and share one. When researchers measured this on benchmark data, the similarity scores of correct hits and wrong hits overlapped heavily. So one threshold for everything is either unsafe or throws away most hits. Their fix, vCache, learns a separate threshold for each cached entry as traffic comes in, and keeps errors under a bound you choose. On their benchmarks that gave up to 12.5 times more hits and 26 times fewer errors than a fixed threshold.
Either way, build a small set of question pairs labeled "same answer" or "different answer" and measure the wrong-hit rate before shipping, like any other eval.
The rule also breaks when the question isn't the only thing that matters. The lookup only compares questions. If the right answer depends on who's asking, the date, or earlier turns in a conversation, the cache can't see that. Some of it can go into hard labels on each entry: which customer, which language, which model or prompt version wrote it. The search only looks at entries with matching labels, so one customer never gets another's answer, and an answer from last month's prompt doesn't outlive a change. Anything personal or time-sensitive is usually better left out of the cache.
Someone can aim for a hit
To work at all, a semantic cache has to send similar inputs to the same entry. A secure hash is built to do the opposite. So it's easy, by design, to craft an input that collides with an entry on purpose. One 2026 attack did this automatically and hijacked responses 86% of the time, even pushing an agent into harmful actions, and it worked across different embedding models. So treat a shared cache as reachable by attackers.
So how much does it save? Vendors quote numbers like "30% or more" less token spend for FAQ bots, without published data behind them. It depends entirely on how repetitive our traffic is, because only questions that come back within the expiry window can hit. Measure that on real logs first.
Further reading
- Redis semantic cache, Redis docs. A practical design with thresholds, labels and expiry in one lookup.
- vCache: Verified Semantic Prompt Caching, Schroeder et al., ICLR 2026. Read the introduction for why one fixed threshold misbehaves.
- From Similarity to Vulnerability: Key Collision Attack on LLM Semantic Caching, Zhang et al., ICML 2026. The security side, if your cache is shared.