What Is Prompt Caching?

What Is Prompt Caching?

What Is Prompt Caching?

Prompt caching makes large language models faster and cheaper by reusing work they have already done. When you send a long prompt, the model must read and process every word before answering, and it repeats that work every time the same instructions are sent. Prompt caching stores the processed version of the repeated part, so the model can skip to the new bit.

The repeated part is often the biggest part. A support bot may reuse the same ten-page product manual in every conversation. A coding assistant may reuse the same project files in every request. Without caching, you pay the full price in time and money for that repeated text every single time.

This guide explains what prompt caching is, how it works, the main types you will meet, and where it saves real money. It also covers the limits and risks, the tasks it suits best, and how to decide whether it is worth setting up for your own work in 2027.

Key takeaways

  • Prompt caching stores the processed version of a repeated prompt so the model can reuse it.
  • It cuts cost and response time when the same long context is used again and again.
  • Caching works best for stable text: system instructions, documents, and examples that rarely change.
  • It does not make the model smarter; it only makes repeated work cheaper and faster.
  • Check your provider’s rules on cache lifetime and pricing, because cached data expires.

At a glance

Prompt caching at a glance
Detail What to know
What it is Reusing a model’s processed prompt instead of reprocessing it
Main benefit Lower cost and faster replies on repeated long prompts
Typical saving Cached input often costs roughly a tenth of fresh input; check current pricing
Best for Long system instructions, documents, and examples reused across many requests
Cache lifetime Minutes to hours depending on the provider; unused caches expire
First request Full price and full processing time; savings start on the second use
Biggest limit Only the exact repeated prefix is reused; changing the start breaks the cache

What prompt caching means in plain terms

Think of a prompt as a briefing you hand to a very fast but forgetful colleague. Every new question means handing over the whole briefing again. Prompt caching leaves the briefing on their desk: next time, they only need the new question.

Close-up of hands typing on a laptop keyboard with code on the screen
Prompt caching saves the most time when the same long instructions are reused across many requests.

The idea is not new: browsers store images so pages load faster, and databases store common answers. Prompt caching applies the same trick to AI models. What gets stored is the model’s internal processed version of the text, which is expensive to create and cheap to reuse.

How prompt caching works

When a language model reads a prompt, it turns the words into internal numbers called a key-value cache. Building that cache is the slow, expensive part; generating the answer is quick. Without caching, the model rebuilds it for every request, even if most of the prompt is identical.

With caching, the provider stores that processed version after the first request. On the next request, it checks whether the start of the new prompt matches. If it does, the model loads the stored version and only processes the new text. If not, the model starts from scratch.

Cache hits and cache misses

A cache hit is when the new prompt matches the stored one and reuse happens. A cache miss is when it does not match, and the model does the full work again. Good caching design is mostly about maximising hits: keeping the repeated part stable, putting it at the start, and sending new requests before the cache expires.

Why the start of the prompt matters

Most prompt caching only reuses a prefix: the unbroken run of text from the very start of the prompt. Change a word near the beginning, and everything after it must be processed again. That is why the standard advice is to put stable content first: system instructions, then documents, then examples, and the changing question last.

Types of prompt caching

Not all prompt caching works the same way. The two main types are explicit caching, where you mark the parts to cache, and automatic caching, where the provider decides. Some providers also offer longer-lived caches for an extra fee.

Explicit caching

With explicit caching, you tell the provider exactly which parts of the prompt to store, usually by marking breakpoints in your request. You decide what is stable enough to cache, and you can see whether each part hit or missed. It takes more setup, and works best when your prompts have a clear, stable structure.

Automatic caching

With automatic caching, the provider watches for repeated prompts and caches them without you doing anything. This is the easiest option, and it suits teams using an AI tool rather than building one. The trade-off is less visibility and less control over what gets cached.

Long-lived and extended caches

Some providers let you pay extra to keep a cache alive for hours instead of minutes. That suits prompts reused rarely but very expensive to rebuild, such as a large codebase. For most everyday uses, the standard lifetime is enough.

Benefits and risks

The benefits are straightforward: faster replies and lower bills for users who would otherwise wait while the model re-reads the same long document. For a support chatbot, faster replies mean shorter conversations. For a research tool, lower costs mean more questions.

Caching also makes long-context work practical. Without it, a tool that reads a hundred-page document for every question becomes slow and expensive. With it, the document is processed once and questioned many times.

The risks to watch

The main risk is staleness. If the cached document changes, the model may keep answering from the old version until the cache expires. Refresh the cache whenever the source changes. The second risk is privacy: cached prompts sit on the provider’s systems, so only cache sensitive documents with a provider you trust.

When caching does not help

Caching does nothing for short prompts, one-off questions, or prompts that change completely every time. If each request is new from start to finish, there is nothing to reuse. It also does not help when the expensive part is generating a long answer rather than reading a long prompt.

Real-world uses

Customer support is the clearest example. A support bot that knows the product manual, the returns policy, and the troubleshooting steps can answer thousands of questions a day from the same cached knowledge.

Coding assistants are a second strong use. A developer’s project files and coding standards stay the same across a whole session, while each request is a new small question about that code. Caching the project context makes each answer quicker and cheaper.

Research and document work is a third use. A lawyer, analyst, or student asking twenty questions about one long report benefits enormously: the report is processed once, and each question costs a fraction of the first. Our guides to the best AI tools for document summarization, the best AI tools for research writing, and the best AI writing tools in 2027 all cover tools where this pattern is common.

Prompt caching vs starting from scratch

Without caching, every request is a fresh start: the model reads the full prompt, processes it, and then answers. That is simple and always correct, because nothing stale can sneak in. The price is time and money, paid in full on every request.

With caching, the first request costs the same as before, and every matching request after it costs less and returns faster. The price is complexity: prompt order, cache lifetime, and stale data. The trade is worth it when the repeated text is long, stable, and reused often.

A useful rule of thumb: under a thousand tokens, do not bother. Over ten thousand tokens reused more than a few times an hour, caching is almost certainly worth it. Between those two, measure first: most providers show cache hit rates in their dashboards.

What prompt caching costs

Prompt caching usually changes the price of input tokens, not output. The first time a prompt is processed, you pay the standard rate. On later requests, the cached part is charged at a much lower rate, often roughly a tenth of the standard price. Check current pricing with your own provider before you plan a budget around it.

Do not forget the hidden costs. Caching adds work for your developers: marking cache points, ordering prompts correctly, and handling stale data. For a team using an off-the-shelf tool, that cost is near zero. For a team building its own integration, budget a day or two of setup.

How to choose the right setup

Start by measuring your own usage. Look at your AI bill or dashboard and find the prompts that repeat: the same instructions, documents, or examples. If one stable block appears in most of your requests, that is your caching candidate.

Then pick the simplest option that fits. If your provider offers automatic caching, turn it on and watch the hit rate for a week. If you build your own integration, explicit caching gives you more control. Only pay for extended lifetimes when your caches keep expiring before they are reused.

Finally, set a review routine. Check the hit rate monthly, refresh cached documents when their source changes, and remove caches you no longer use. Caching is not a setting you turn on once and forget.

Checklist: getting value from prompt caching

  • Repeated text identified: one stable block appears in most requests.
  • Prompt order fixed: stable content first, the changing question last.
  • Cache type chosen: automatic for off-the-shelf tools, explicit for custom integrations.
  • Pricing checked: cached token rate confirmed with your provider.
  • Staleness handled: cached documents refreshed whenever the source changes.
  • Hit rate reviewed: cache hits measured monthly to confirm the savings.

Frequently asked questions

Is prompt caching the same as saving chat history?

No. Chat history saves the conversation so you can read it later. Prompt caching saves the model’s processed version of the prompt so it can reuse the work. History is for people; caching is for the model.

Does prompt caching change the answers?

It should not. A cache hit gives the same result as processing the prompt fresh. If you ever see different answers, the cause is usually a stale cache holding an old version of the document. Refresh the cache and the problem goes away.

How long does a prompt cache last?

Minutes to a few hours is typical for a standard cache. A cache also expires if it is not used, so a prompt reused once a day may never hit, while one reused every minute almost always will.

Is prompt caching safe for private documents?

It is as safe as the provider holding the cache. Read the provider’s data terms before caching sensitive documents, and avoid caching anything you would not send to that provider anyway. For highly sensitive material, keep the cache lifetime short.

Do I need to be a developer to use prompt caching?

No. If you use an AI tool with automatic caching, it works without you doing anything. Developers only need to get involved for explicit caching in a custom integration. Most users will never touch a setting.

When is prompt caching not worth it?

When your prompts are short, change completely each time, or are used only once. Caching only pays when the same long text is reused often. If your requests are all one-off questions, the cache will miss every time.

The bottom line

Prompt caching is a simple optimisation with an outsized payoff for the right workloads: long, stable prompts reused many times. It does not make a model smarter, and it will not help a short one-off question. But for support bots, coding assistants, and document research, it turns a cost that grows with every question into one paid mostly once.

Find the text you repeat, put it first in the prompt, turn on your provider’s caching, and check the hit rate after a week. If the numbers confirm the saving, keep it. If they do not, turn it off.

on this page