# Semantic caching

> Canonical: https://skillalmanac.com/glossary/semantic-caching | Last verified: 2026-11-25 | Index status: index-eligible

Semantic caching stores past language-model answers and reuses one when a new question means roughly the same thing, found by comparing embeddings (numeric representations of meaning) instead of matching exact text. It saves model calls when many users ask alike.

Also called: semantic cache, semantic cache LLM.

## In plain language

Think of a help desk that keeps a folder of answers. A normal cache only reuses an answer when the question is word for word the same. A semantic cache also recognises that 'How do I reset my password?' and 'I forgot my login' ask for the same thing, and hands back the saved answer without asking the model again. That can cut cost and waiting time for busy apps. The limit is that 'close enough' is a judgement: if the match setting is too loose, a person can get an answer written for a different question, and a saved answer can go out of date. Use it where repeated questions have stable answers.

## Technical definition

A semantic cache converts each incoming query to an embedding, searches a vector store of earlier queries for near neighbours, and applies a similarity threshold. Above it, the stored response is returned (a cache hit); below it, the request goes to the model and the new query embedding and response are stored (a miss). The GPTCache project describes a pipeline with an embedding step, a vector store and a similarity evaluator, and contrasts this with exact-match caching. Redis describes tuning the threshold as a trade-off between accuracy and breadth, and time-to-live values for stale answers. Provider prompt caching, such as Anthropic's, is a different mechanism: it reuses an identical prompt prefix.

## How it shows up when you use agents

Semantic caching sits in front of a model, usually in an application you or your team builds, such as a support chatbot or an internal question-and-answer tool. Do not infer the caching mechanisms or defaults of every coding product from this definition. One documented mechanism is provider [prompt caching](/glossary/prompt-caching), which reuses an identical beginning of the prompt. Anthropic's documentation says cache hits require identical prompt segments. A semantic cache works the other way round: the wording can differ, and an [embedding](/glossary/embedding) comparison decides whether two questions are close enough.

What breaks when the two are mixed up: a team expects a long coding session to get cheaper because "caching is on", then finds that changed instructions or a changed tool list reset the provider cache. Or a team adds a semantic cache to a workflow where each question depends on live data, and users receive stale or wrong-question answers. Redis's own guide says the similarity threshold needs careful tuning, and that cached data needs a plan for staying consistent with its source.

A sensible next step is to measure first. Examine candidate repeated requests for meaning, user context and answer freshness, then test any threshold before serving cached answers. Estimate valid avoided model calls separately. The [LLM cost estimator](/skills/skill-almanac/llm-cost-estimator) can price the remaining workload using supplied rates, but its cache option models identical-prefix reuse, not semantic response hits. See [inference cost](/glossary/inference-cost) for what is being saved.

## Common confusions

- **Semantic caching versus prompt caching.** Prompt caching reuses an identical prompt prefix inside the provider. Semantic caching matches new questions to old ones by meaning and returns a stored answer without calling the model.
- **Semantic caching versus retrieval.** Retrieval (see [retrieval-augmented generation](/glossary/retrieval-augmented-generation)) fetches documents to help the model write a fresh answer. A semantic cache returns a finished answer that was written earlier.
- **Cache hit versus correct answer.** A hit means the match score passed the threshold. It does not guarantee the old answer fits the new question.
- **Myth: it suits all workloads.** Where answers change often or depend on the individual user, a saved answer can mislead; the Redis guide discusses time-to-live settings for this reason.

## Worked examples in this catalogue

### [llm-cost-estimator](https://skillalmanac.com/skills/skill-almanac/llm-cost-estimator)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A monthly LLM cost range built from a usage profile and your own price table, with cache, batch and subscription effects included.

Why it exercises the concept: A prefix-cache pricing contrast: this estimator models identical-prefix reuse, not semantic response hits. For a hypothetical semantic-cache scenario, first estimate valid avoided model calls separately, then supply the remaining workload; embedding and lookup costs need separate accounting.

### [agent-session-cost-review](https://skillalmanac.com/skills/skill-almanac/agent-session-cost-review)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A report of where a coding-agent session spent its tokens, read from the saved session transcript by a script.

Why it exercises the concept: A transcript spend report can identify repeated reads or expensive phases as candidates for investigation. It does not establish that questions have interchangeable meanings or that a saved answer is still correct.

### [Claude Code Pricing: What Drives Cost and Plan Options](https://skillalmanac.com/learn/claude-code-pricing-explained)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: An explanation of how Claude Code usage is billed, including a sample usage output where most tokens were cached context re-read on each turn.

Why it exercises the concept: It shows the other kind of caching you meet in agent work, provider prompt caching of an identical prefix, which is easy to confuse with semantic caching.

### [Claude Code](https://skillalmanac.com/tools/claude-code)

```
/usage
```

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Claude Code shows plan usage and the session's token use, which the cost documentation breaks down into input, output and cache-read tokens.

Why it exercises the concept: It makes the difference visible: cache-read tokens here come from reusing an identical prefix, not from matching questions by meaning.

## Related terms

- [Prompt caching](https://skillalmanac.com/glossary/prompt-caching.md)
- [Embedding](https://skillalmanac.com/glossary/embedding.md)
- [Semantic search](https://skillalmanac.com/glossary/semantic-search.md)
- [Inference cost](https://skillalmanac.com/glossary/inference-cost.md)
- [Vector database](https://skillalmanac.com/glossary/vector-database.md)
- [Retrieval-augmented generation (RAG)](https://skillalmanac.com/glossary/retrieval-augmented-generation.md)

## Sources

- [GPTCache: a library for creating semantic cache for LLM queries](https://github.com/zilliztech/GPTCache), Zilliz (GitHub) (accessed 2026-11-24)
- [What is semantic caching? Guide to faster, smarter LLM apps](https://redis.io/blog/what-is-semantic-caching/), Redis (accessed 2026-11-24)
- [Prompt caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching), Anthropic (Claude Docs) (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
