Skip to content
Agent Month

Semantic caching

Last verified: June 2026· definition

An exact-match cache only helps when two requests are byte-identical. A semantic cache embeds the incoming request and looks for a previous request whose meaning is close enough, returning the stored answer instead of paying for a fresh generation.

It shines on workloads with a hot set of common questions — support assistants, docs Q&A, internal helpers — where users ask the same thing a hundred different ways. Hit rates of 20–40% are realistic on that shape of traffic, and every hit is a request you did not pay for and did not wait for.

The risk is a false hit: returning a cached answer for a question that only looked similar. That is a tuning problem (similarity threshold, namespacing by user or tenant, TTLs on volatile data) and, like every cost optimization, it should sit behind an eval so you can prove quality held.

The similarity threshold is the whole design

Semantic caching returns a stored answer when a new request means the same thing, which requires deciding how close counts as the same. Set it loosely and users receive answers to questions they did not ask, which is worse than a cache miss because it is wrong rather than slow. Set it tightly and the hit rate collapses to roughly what exact matching would have achieved. There is no universally correct value — it depends on how much question variation genuinely maps to identical answers in your domain.

It fails differently from exact caching

An exact-match cache is either correct or empty. A semantic cache can be confidently wrong, serving a plausible answer to a subtly different question, and the failure is invisible in metrics that only track hit rate. Because the error looks like a normal response, detecting it requires sampling served hits and checking whether the cached answer genuinely addressed the new query.

Personalisation and permissions make it dangerous

If answers depend on who is asking — their data, their entitlements, their tenant — a cache keyed on question meaning alone will serve one user’s answer to another. Any cache in such a system must incorporate identity or scope into the key. This is a straightforward mistake to make and a serious one, because it presents as a caching optimisation and behaves as a data leak.

Where it fits well

The strong case is a bounded domain with high question repetition and answers that do not vary by user: documentation assistants, support systems over a fixed knowledge base, FAQ-style retrieval. There, many differently-worded questions genuinely have one right answer, which is exactly the condition the technique needs. In open-ended assistants with personalised context, the conditions rarely hold.

Common misconceptions

  • MythSemantic caching is just caching with fuzzy matching.

    RealityThe fuzziness changes the failure mode from a miss to a potentially wrong answer, which needs monitoring that exact caching does not require.

  • MythA high hit rate means it is working.

    RealityHit rate rises as the threshold loosens, and so does the rate of wrong answers. Without sampling served hits for correctness, the metric flatters exactly the misconfiguration you want to catch.

  • MythIt works for any LLM feature.

    RealityIt needs repeated questions with user-independent answers. Where responses depend on personal data or permissions, caching on meaning alone will serve answers across users.

Frequently asked questions

How is semantic caching different from prompt caching?

They operate on different things. Prompt caching reuses the model’s processing of a repeated input prefix — the model still generates a fresh response, and quality is unaffected. Semantic caching skips generation entirely, returning a previously produced answer because the new question is judged to mean the same as an earlier one. Prompt caching is a safe optimisation; semantic caching is a trade with a correctness risk attached.

How do I choose a similarity threshold?

Empirically, and with correctness rather than hit rate as the target. Collect real query pairs your cache would treat as matches at various thresholds, and have someone judge whether the stored answer genuinely answers the new question. That establishes where wrong answers begin, and the threshold belongs on the safe side of it. Tuning on hit rate alone optimises directly toward the failure you are trying to avoid.

Is semantic caching safe for user-specific answers?

Not without incorporating identity into the cache key. If answers depend on a user’s data, permissions, or tenant, caching purely on question meaning will serve one user’s response to another — a data leak that presents as a performance optimisation. Where responses are heavily personalised, the achievable hit rate after correct scoping is often low enough that the technique is not worth its risk.