Semantic Caching for LLM Chatbots: GPTCache vs Portkey vs Redis (2026)
Semantic caching for LLM chatbots compared - GPTCache vs Portkey vs Redis. How it works, hit rates, similarity thresholds, and what not to cache.
Answer first: semantic caching stores the embedding of each chatbot query alongside the LLM’s response, then serves that stored answer whenever a new question is close enough in meaning - skipping the model call entirely. It typically lands 25-35% cache hit rates on real chatbot traffic. For most teams: reach for GPTCache if you want control, Portkey if you want it managed, and Redis if you already run it.
Semantic Caching for LLM Chatbots: GPTCache vs Portkey vs Redis (2026)
Every production chatbot answers the same handful of questions thousands of times a day, worded slightly differently each time. “How do I reset my password?” and “I forgot my password, what now?” are the same request to a human and two entirely different strings to a literal cache. A traditional exact-match cache never fires on the second one. Semantic caching does, and that is why it has become a default cost-and-latency lever for LLM chatbots in 2026.
This guide explains how semantic caching works, how it differs from prompt caching (a common confusion), the three main ways to run it - GPTCache, Portkey, and Redis - and the design decisions that separate a cache that saves money from one that quietly ships wrong answers. It pairs with our guide on how to cut LLM costs for production chatbots and AI agents.
What is semantic caching?
Semantic caching is a cache that matches on meaning instead of exact text. When a query comes in, you compute its embedding (a vector), store that vector plus the LLM’s answer, and index it in a vector store. On the next query, you embed it, search for the nearest stored vector, and if the similarity clears a threshold you return the cached answer without calling the model.
The payoff over a literal cache is large because human phrasing varies enormously. An exact-string cache only fires when two users type identical characters; a semantic cache fires whenever they mean the same thing. On typical chatbot workloads that difference shows up as 25-35% cache hit rates - a direct cut to token spend and a latency win, because a vector lookup returns in milliseconds while an LLM call takes seconds.
That hit-rate share is pure savings: no output tokens billed, no model latency, no rate-limit pressure. The other 65-75% still hits the model, so semantic caching is a lever, not a silver bullet - but it is one of the cheapest levers you can pull.
Semantic caching vs prompt caching?
This is the confusion worth clearing up before you build anything, because the two are complementary, not alternatives.
Prompt caching is a provider-side discount. When your requests share a long common prefix - a big system prompt, a fixed instruction block, retrieved context reused across turns - the provider caches those prefix tokens and bills them at a steep discount on repeat. You still make the call and still get a fresh generation; you just pay less for the repeated input tokens. We cover it in depth in prompt caching explained.
Semantic caching skips the call. There is no generation, no output tokens, no provider round-trip - you return a stored answer.
| Prompt caching | Semantic caching | |
|---|---|---|
| What it caches | Repeated prefix tokens | Full query-and-answer pairs |
| Where it lives | At the provider | Your infrastructure or gateway |
| Does it call the model? | Yes, discounted | No, skipped |
| Best for | Long shared context per call | Repeated similar questions |
Run both. Prompt caching cheapens the calls you have to make; semantic caching removes the ones you do not.
GPTCache vs Portkey vs Redis: the three approaches
There are three practical ways to add semantic caching to a chatbot, and they differ mostly in how much you want to own.
| Tool | Type | Hosting | Control | Best for |
|---|---|---|---|---|
| GPTCache | Open-source library | Self-hosted | Highest - pluggable embeddings and vector stores | Teams that want full control and no vendor in the path |
| Portkey | Managed AI gateway | Managed (or self-host) | Lowest - config, not code | Teams that want caching plus routing and observability turned on fast |
| Redis | Vector store / cache backend | Self-hosted or managed | Medium - you wire embeddings and thresholds | Teams already running Redis who want to reuse it |
GPTCache is an open-source semantic caching library. You choose the embedding model and the vector store, run it yourself, and it eliminates redundant API calls for similar queries. It gives you the most control and the most to operate - you own the embeddings, the similarity logic, the eviction policy, and the uptime.
Portkey is a managed AI gateway with semantic caching built in, alongside routing, fallbacks, and observability. If you want caching as a config toggle rather than a service to run, this is the fastest path - and you get the rest of the gateway for free. See our LLM gateways compared for how it stacks up against LiteLLM, Helicone, and Cloudflare.
Redis is the pragmatic choice when Redis is already in your stack. Using Redis vector search (LangCache-style) as the semantic cache backend means you reuse infrastructure your team already operates and monitors. You wire the embedding step and pick the similarity threshold yourself, so it sits between GPTCache’s full control and Portkey’s turnkey convenience.
How do you avoid wrong cache hits?
The failure mode of semantic caching is not a miss - it is a wrong hit, where the cache confidently returns an answer to a different question. Four design decisions keep that from happening.
Similarity threshold. This is the whole game. Set it too loose and “how do I cancel my subscription” returns the answer for “how do I upgrade my subscription.” Set it too tight and you miss obvious rephrasings and your hit rate collapses. Start conservative, log every near-miss with its similarity score, and raise recall deliberately once you can see where the boundary actually sits. Do not guess it once and walk away.
Cache invalidation and TTL. A cached answer is only correct until the underlying facts change. Put a TTL on entries so stale answers expire, and invalidate proactively when the source of truth changes - a pricing update, a policy change, a new product. An indefinitely cached answer to “what is your refund window” becomes a liability the day the policy changes.
What not to cache. Some responses should never enter a shared cache: personalized answers (“what is my account balance”), time-sensitive ones (“is my order shipped yet”), and auth-gated content. Route these straight past the cache. A good rule: if the correct answer depends on who is asking or when, do not cache it in a shared store.
Per-user vs shared cache. A shared cache is efficient but dangerous for anything user-specific - it can leak one user’s answer to another. Use a per-user or per-tenant cache namespace for anything touching personal data, and reserve the shared cache for genuinely generic questions.
What does this mean for UAE and GCC deployments?
For chatbots serving UAE users, the per-user cache decision is a compliance decision, not just an engineering one. Under the UAE Personal Data Protection Law (PDPL), returning one user’s cached response to another is an unauthorized disclosure of personal data. The controls are straightforward but non-negotiable: scope any cache that can contain personal or account data to a per-user or per-tenant namespace, exclude auth-gated responses from the shared cache entirely, and keep TTLs short on anything that could become misleading if stale.
Done right, semantic caching actually helps your data posture: fewer calls to the model provider means less personal data leaving your boundary in the first place. The shared, generic cache - password resets, opening hours, how-to answers - carries no personal data and can run wide open, while the per-user layer stays tightly scoped. This is the kind of split we build into enterprise AI integrations for GCC clients.
Which tool should you use?
Match the tool to how much you want to run:
- Choose GPTCache if you want an open-source, self-hosted semantic cache with full control over the embedding model, vector store, and eviction policy - and you have the team to operate it.
- Choose Portkey if you want semantic caching as part of a managed gateway, switched on with config, bundled with routing and observability, and you would rather not run cache infrastructure.
- Choose Redis if you already run Redis and want to reuse it as the vector store, accepting that you wire the embedding and similarity threshold yourself.
For most teams starting out, Portkey is the fastest way to prove the savings, and GPTCache or Redis are the natural moves once you want more control or already own the infrastructure. Whichever you pick, the caching layer is the easy part - the threshold tuning, invalidation strategy, and per-user isolation are where the real work lives.
Building it right
Semantic caching is one of the highest-return, lowest-risk optimizations you can add to a production LLM chatbot - if you get the threshold, invalidation, and privacy scoping right. Get them wrong and you ship confident wrong answers or leak data across users. The tooling choice between GPTCache, Portkey, and Redis matters less than those three design decisions.
NomadX is an AI agents consultancy in Dubai that builds production chatbots and agents for UAE and GCC enterprises - with semantic caching, cost controls, and PDPL-aligned privacy scoping built in from the start. If you want to cut your chatbot’s token bill without shipping wrong answers, book a free 30-minute consultation.
Frequently Asked Questions
What is semantic caching and how much does it save?
Semantic caching stores the embedding of each query alongside the LLM's answer, then returns that cached answer when a new query is semantically similar - not just an exact string match. Because real users phrase the same question many ways, it catches far more repeats than a literal cache. Typical chatbot workloads see 25-35% cache hit rates, cutting token cost and latency on that share of traffic.
Semantic caching vs prompt caching - what is the difference?
They solve different problems. Prompt caching is a provider feature that discounts repeated prefix tokens (a long system prompt or shared context) when you still call the model. Semantic caching skips the model call entirely by serving a stored answer for a similar past question. Prompt caching cheapens the call; semantic caching removes it. Most production chatbots use both together.
How do you avoid wrong answers from a semantic cache?
Tune the similarity threshold. Too loose and the cache returns an answer to a different question; too tight and it misses real repeats. Start conservative, log near-miss hits, and raise recall gradually. Pair it with sensible TTL and cache invalidation, and never cache personalized, time-sensitive, or auth-gated responses.
Which semantic caching tool should I use?
Use GPTCache if you want an open-source, self-hosted library with full control over embeddings and vector store. Use Portkey if you want semantic caching switched on inside a managed AI gateway with routing and observability. Use Redis as the vector store when you already run Redis and want to wire the embedding and similarity logic yourself.
Is semantic caching safe for user privacy under UAE PDPL?
Only if you scope it correctly. A shared cache can leak one user's answer to another, which breaches confidentiality and UAE PDPL obligations. Use a per-user or per-tenant cache for anything containing personal or account data, exclude auth-gated responses from the shared cache entirely, and set short TTLs on anything that could go stale.
Complementary NomadX Services
Related Articles
Get Started for Free
Schedule a free consultation with our AI agents team. 30-minute call, actionable results in days.
Talk to an Expert