Glossary

Semantic Caching

Semantic caching serves a stored response to a request that means the same thing as an earlier one, matching on meaning rather than on an exact string.

Semantic caching serves a stored response to a request that means the same thing as an earlier one, rather than only to a request that is character-for-character identical. Each incoming prompt is converted to an embedding — a numeric vector representing its meaning — and compared against the vectors of cached prompts, usually by cosine similarity. Above a configured similarity threshold, the cached response is returned and no model call is made.

The economics are the reason it exists. Enterprise AI traffic is far more repetitive than it looks: the same policy question, the same summary of the same document, the same lookup, phrased a hundred ways by a hundred people. Exact-match caching catches almost none of it. Semantic matching catches the repetition that natural language hides.

How it differs from a traditional cache. A conventional cache keys on an exact string. It is deterministic and safe, and on natural-language traffic it almost never hits. A semantic cache keys on meaning, which means the threshold is now a real decision: too loose and it answers a question nobody asked, too tight and it behaves like an exact-match cache. The threshold is a governance setting, not a tuning detail.

How it differs from fine-tuning or RAG. Both change what the model knows. A cache changes whether the model is called at all. They are complementary, and the cache is the only one of the three that reduces spend directly.

Smartflow's MetaCache resolves a lookup in four phases, first hit wins: intent signature, intent near-miss, exact key, then a VectorLite BERT semantic match. Compression runs after a miss rather than as a phase of the lookup, and compaction runs continuously. A prewarm job refreshes hot intent entries on a default six-hour interval where Redis is present. Hit rates and token savings are workload-dependent.

AI cost optimization

The threshold is a governance setting

Every semantic cache has a similarity threshold, and it is usually treated as a performance dial. It is not. Set it loose and the system confidently answers a question nobody asked. Set it tight and it degrades to exact matching and saves nothing. In a regulated environment the threshold, and every change to it, belongs in the same versioned record as the rest of the policy — because a cached answer served to the wrong question is a governance event, not a cache miss.

The other consideration is what the cache is allowed to hold. A cached completion is stored content, subject to the same classification and retention rules as anything else, which is why caching sits inside the control plane rather than beside it. The cache ecosystem, token savings and least-cost routing cover the mechanism; the cost optimization approach covers why the metering point and the enforcement point should be the same wire. Threshold changes are governed as policy as code. Gateways that cache on exact match only are compared on the Cloudflare AI Gateway page.

Policy as code · DLP for AI · AI sovereignty · Runtime governance · Model allowlist and deny-list · Full glossary

Put this in the path of your own agents.

Policy enforced inline between your agents and every model and tool they reach, with a record bound to the human who owns it.

Request a Demo Read the docs