Skip to content
AI-Native PM

Caching: never pay for the same thinking twice

Chapter 5 of 8 in The Unit Economics of AI · 19 min

You launch a documentation assistant without much fanfare, and it works: it answers how to rotate an API key, what the rate limits are and how to invite a teammate, correctly and in seconds. When finance forwards the month's invoice, you pull the logs and find that about twenty questions account for most of the traffic, each asked hundreds of times in nearly the same words by people who will never meet. The questions are public and the answers barely changed all month, yet you paid for the full run every time someone asked: the model processed the same system rules again, the product retrieved the same pages again, and the model produced the same answer again from scratch. You were billed as if every person asking were the first, and almost none of them were.

The three caches: prompt, response, and semantic

Caching means storing work you have already paid for and reusing it when someone needs the same thing again. AI products use three kinds of cache, and each one saves a different kind of repeated work.

Prompt caching: pay less for the same opening text. Most of a production prompt does not change between calls: the system rules, the tool definitions and the shared documents sit at the start of every request, and only the user's question at the end changes. Prompt caching is a discount on that unchanged opening part of a request. The provider stores the opening part after the first call and on later calls processes only the new text at the end, and it bills the tokens it reads from the cache at a small fraction of the normal input rate. The exact ratios change with provider pricing, so the current numbers are in the dated Price Sheet. What stays true is that the discount on the cached part is large, and on long prompts the cached part is most of the input bill.

Response caching: skip the model call for an exact repeat. When someone asks the same question again, in exactly the same words and with nothing personal in it, you send back the stored answer and make no model call at all. You save the whole cost of the call, but the cache works only when the new question matches a stored one word for word.

Semantic caching: skip the model call for a question that means the same thing. "How do I reset my password" and "how can I change my password if I forgot it" are different strings that need the same answer. A semantic cache compares a new question with stored ones by meaning, usually by comparing embeddings (lists of numbers that represent what a text is about), and sends back the stored answer when the match is close enough. It finds a match far more often than exact matching does, and it is the riskiest of the three caches, because deciding what is "close enough" is a judgment call: "how do I enable notifications" and "how do I disable notifications" score as almost identical in meaning, yet need opposite answers.

In the diagram, titled CACHE LEDGER, the provider bills the STABLE opening part of each prompt at a fraction of the input rate (marked 0.1X, an illustrative ratio; current ratios are in the Price Sheet), while the part that CHANGES EVERY CALL is billed in full; the response cache gives two identical refund questions one stored answer; and the semantic cache matches "refund?" with "money back?", with the warning CLOSE MATCH: CHECK IT, because deciding when two questions are close enough to share an answer is a judgment call.

The documentation assistant in the opening scene can use all three at once: prompt caching for the rules and pages every question shares, response caching for the questions people ask word for word, and semantic caching for reworded versions of those questions.

What you can cache is a product decision

Which caches fit your product depends on what your users ask and how personal the answers are. Content is worth caching when it is stable and shared: the product's own rules, public documentation, policy text, anything where everyone who asks should get the same answer. Three kinds of content cannot be shared across users through a response or semantic cache:

  • Personalized. An email assistant drafting from one user's inbox, or a meeting tool summarizing one team's call, produces answers no other user should ever receive.
  • Time-sensitive. A research tool reporting on this morning's filings, or a support bot quoting current wait times, answers questions whose correct answer changes faster than any sensible cache lifetime (how long the cache may keep serving a stored item).
  • Memory-dependent. An answer built on what the user said three messages ago belongs to that session and no other.

This is also why the order of your prompt matters. Providers cache only the opening part of a request that matches earlier requests exactly, so the first personalized token ends the discount, and everything after it is billed at the full rate.

Put the stable content first in every prompt: the provider caches only the unchanged opening part, so moving the parts that change from call to call toward the end makes the discounted part longer.

This matches the split in Context budgets: fit the right facts into a finite window, where the system rules take a fixed share of the context window while memory, retrieved facts and history change from request to request. Prompt caching discounts whatever stays the same on every request (the system rules, the tool definitions and any documents every request shares) only while you keep it at the start of the prompt and keep it truly unchanged.

Decide how long each cached answer may go unchecked

Every time you cache an answer, you are deciding how long that answer may go unchecked: you save the cost of producing it again, and you also stop checking it until it expires.

A stored answer was correct on the day it was stored, and when you serve it again you are betting that nothing relevant has changed since. Usually that is a safe bet, which is why caching works at all, but when the bet is wrong, nothing warns you: a response cache in front of a support bot keeps serving last quarter's refund policy in the bot's usual confident tone, and nothing in the answer shows how old it is.

In Freshness and conflicts: govern the knowledge you answer from you gave each content class (a group of documents of the same kind, such as policies) a freshness SLA (service-level agreement): a deadline by which its documents must be re-verified or retired, so that answers built on them reflect changes in the world within a known time. Your cache lifetimes either keep those deadlines or break them, because the cache does not check a stored answer again before it expires. If policy answers must reflect a change within a day, no cached policy answer may be served for longer than a day, and when a source document changes, delete the answers built on it right away instead of waiting for them to expire on schedule. In the diagram, the clock labeled SHELF LIFE stands for these lifetimes: no cached answer should be served past the shelf life of the content behind it (how long that content stays accurate).

Measure how much your traffic repeats before you build a cache

A cache saves money only when requests repeat, and you measure repetition with the cache hit rate: the share of requests served from the cache instead of paid for in full. You can work out this number in advance, because a week of production logs shows how much of your workload repeats before you build anything, and a workload with no repetition gets nothing from a cache.

Go through the same week of logs three times, once for each cache. Prompt caching applies to nearly every call as long as requests share the same opening part, so it fits almost any production workload. Response caching applies only where the logs show word-for-word repeats, which are common for public documentation questions and rare for personal assistants. The share of requests a semantic cache can answer from storage falls between the other two, and where it falls depends on the matching threshold you choose (how close in meaning two questions must be to share an answer). You then have to defend that threshold with spot checks for matches that would give a wrong answer. A support bot's team may find that a small set of questions covers half its traffic, while a research assistant's team may find every query unique, which leaves prompt caching as the only cache that fits. Both findings are useful, and you can get either one from the logs before you have built anything.

Try it now

This drill costs no new tokens, and by the end you will know which caches are worth building for your workload.

Pull a week of real prompts. Export a week of requests from your product's logs, or, if you have no production traffic yet, use a week of your own assistant history as a stand-in. Scale it down: one busy day, or the most recent hundred requests, takes only minutes to sort and still shows the pattern.

Sort them into three piles. By eye, mark each request as an exact repeat of another (the words match), a near-repeat (different words, same intended answer), or a one-off. Sorting by eye is a manual version of the matching a semantic cache does automatically, and the requests you hesitate over are exactly the ones a cache will get wrong.

Estimate the cache hit rate for each cache. Exact repeats over the total is your response-cache hit rate, exact plus near-repeats is the highest hit rate a semantic cache could reach, and the fraction of each prompt that is the fixed opening part (rules, tools, shared documents) is roughly what prompt caching would discount on every call.

Write down which caches fit, with lifetimes. In a few lines, record which of the three caches fit this workload and, for each one you would build, the lifetime you would give its entries, taken from the freshness SLA of the content behind them. Keep the note, because it becomes a line in the budget you put together in Write your Inference Budget and ship a feature that pays for itself.

Chapter Summary

  • Caching means storing work you already paid for and reusing it when someone needs the same thing again, and AI products use three kinds of cache.
  • With prompt caching, the provider stores the unchanged opening part of your request, so on later calls the rules and shared documents it reads from the cache are billed at a small fraction of the normal input rate.
  • Response caching sends a stored answer to an exact repeat of a question and skips the model call entirely.
  • Semantic caching matches questions that mean the same thing and gives them one stored answer; it finds more matches than response caching and carries the most risk, because deciding what is "close enough" is a judgment call.
  • Stable, shared content is worth caching; personalized, time-sensitive and memory-dependent answers should not be served from a response or semantic cache.
  • Order every prompt with the stable content first, because the first changed token ends the cached discount for everything after it.
  • A cached answer goes unchecked until it expires, so give each entry a lifetime set from your freshness SLAs, and delete entries the moment their source changes.
  • Measure the cache hit rate from real logs before you build, because a workload with no repetition gets nothing from a cache.
  • Caching cuts the cost of work that repeats, and Batch and background: choose the realtime line covers how to cut the cost of work that can wait.

Sources

  • Anthropic and OpenAI prompt caching documentation (last verified July 2026).
  • Bang, F. (2023). GPTCache: An Open-Source Semantic Cache for LLM Applications. Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS), EMNLP.
  • Character.AI engineering blog (2024). Optimizing AI Inference at Character.AI.
  • Current cached-token rates and discounts: the dated Price Sheet.