- In short
- Prompt caching stores a stable prefix of a prompt so that repeated requests reusing that prefix avoid reprocessing it, cutting cost and latency for large, unchanging contexts. Only the stable portion belongs before the cache boundary; any content that changes between requests must go after it, or the cache will not hit.
What prompt caching stores and why
Every call to the Claude Messages API reprocesses the full prompt you send, because the endpoint keeps no memory between calls, as covered in the request-response cycle. When you resend the same large block of instructions or reference material on every request, you pay to process that identical text again and again. Prompt caching removes that waste: it stores a stable prefix of the prompt so that later requests reusing the same prefix skip re-processing it and read from the cache instead.
For the Claude Certified Developer - Foundations (CCDV-F) exam, the mental model is a boundary. Everything before the cache boundary is the stable prefix that gets stored and reused; everything after it is fresh content the model still processes normally on each call. The saving comes from the reused prefix, so the design question is always the same: what part of my prompt genuinely does not change between requests, and can I put all of it, and only it, before the boundary?
- Prompt caching
- A mechanism that stores a stable prefix of a prompt so repeated requests reusing that prefix avoid reprocessing it, reducing cost and latency. The prefix must be identical across requests to hit; any content that varies belongs after the cache boundary.
Where caching pays off most
Caching helps most when a large, unchanging context is reused across many calls. The classic shapes are a long system prompt full of standing instructions, a big reference document the model consults on every request, a fixed set of few-shot examples, or a large tool schema. These are expensive to reprocess and they do not change from one request to the next, so caching them converts a repeated cost into a one-time cost plus cheap cache reads.
The economics scale with two factors: how big the stable prefix is, and how often it is reused. A tiny prefix reused rarely saves almost nothing; a large document reused across thousands of requests saves a great deal. This is why caching is a natural fit for applications that answer many questions against the same corpus, or run the same elaborate system prompt over high request volumes. If your context is small or changes every call, caching has little to grab onto, and the honest answer on the exam is that it will not help much.
The cache boundary is the whole design
Because only an identical prefix can hit the cache, where you draw the boundary is the entire skill. Order your prompt so the stable material comes first: system instructions, long documents, fixed examples, tool definitions. Place the boundary after that stable block. Then put everything volatile after it: the user's current question, retrieved snippets that differ per request, timestamps, session identifiers, anything that changes call to call. Structured this way, the expensive stable part is cached once and reused, while the cheap changing part is processed fresh each time.
This ordering discipline connects directly to content boundaries and schema design: a well-organised prompt separates the durable scaffolding from the per-request payload, which is exactly what caching rewards. Get the boundary right and cache hits become routine; get it wrong and you pay full price on every call while believing you optimised.
The two traps the exam sets
The first trap is placing changing content inside the cached prefix, which prevents cache hits. If anything before the boundary varies between requests, even a single injected timestamp, a per-user greeting, or a retrieved passage, the prefix is no longer identical to the stored one, so the cache cannot match and the whole prefix is reprocessed. The symptom is a cache that never seems to hit despite a large, seemingly stable prompt. The cause is nearly always volatile content that leaked in front of the boundary. The fix is to move every changing element after it.
The second trap is expecting caching to improve quality rather than cost and latency. Caching does not change what the model sees or how it reasons; the cached prefix is byte-for-byte the same content it would have processed anyway. So answers do not get better, more accurate, or more consistent because you enabled caching. What you get is cheaper and faster processing of the reused portion. A scenario that proposes caching to "improve accuracy" or "make responses more reliable" is offering the wrong lever; those are prompt- and model-quality concerns, not caching concerns.
Misconception
I put my whole prompt behind the cache, including the user's question and today's date, so it should hit every time.
What's actually true
Misconception
Enabling prompt caching should make Claude's answers more accurate and consistent.
What's actually true
Worked example
A document assistant answers many questions against the same 40-page policy manual and wants to cut cost without hurting answers.
The first design prepends the 40-page manual to every request, followed by the user's question, and reprocesses the entire manual on each of thousands of daily calls. The bill is dominated by re-reading the same document over and over. Caching is the obvious fix: the manual is large and reused on every call, the textbook case where caching pays.
The team caches the system instructions plus the manual as the stable prefix and places the boundary immediately after them, with each user question sitting after the boundary. Now the manual is processed once and read from cache on subsequent calls, while only the short, changing question is processed fresh. Cost and latency for the reused portion drop sharply, and answer quality is exactly the same, because the model still sees the identical manual, just retrieved rather than reprocessed.
A second team copies the pattern but, wanting personalised replies, injects Hello {user_name}, today is {date} at the very top of the prompt, before the manual. Their cache never hits. The greeting changes every request, so the prefix is never identical, and the whole manual is reprocessed every time despite caching being "enabled." Moving the greeting to after the cache boundary, behind the stable manual, restores the hits. Same lesson, seen from the failure side: only truly stable content belongs in the cached prefix.
How this is tested on the exam
Domain 2 questions on prompt caching are diagnostic. A common shape describes a cache that is "not saving anything" and asks for the cause; the answer is that volatile content, a timestamp, a per-user field, a retrieved snippet, sits inside the cached prefix and breaks the match, and the fix is to move it after the boundary. Another shape offers caching as a solution to the wrong problem, usually accuracy or consistency, and expects you to recognise that caching addresses cost and latency, not quality.
Anchor your answers on the two conditions and the two traps. Caching helps when a large, unchanging context is reused across many calls, and only the stable prefix belongs before the boundary. It breaks when changing content leaks into that prefix, and it never improves quality. Those facts, plus the ability to reason about where a cost saving actually comes from, resolve the caching questions and connect to streaming responses, the other Claude API mechanic that developers reach for when they want a faster-feeling application.
A team enables prompt caching for an assistant that answers questions against a large fixed manual. The manual sits at the top of every prompt, but they also prepend a line with the current timestamp before it. Cache hit rates are near zero. What is the fix?
People also ask
What does prompt caching actually cache?
When does prompt caching save the most money?
Does prompt caching improve response quality?
Watch and learn
Official Anthropic Academy lessons first, then hand-picked walkthroughs. Videos load only when you press play.
No videos curated for this concept yet
We are still curating the best official and community videos for this topic.
References & primary sources
Master this concept with Archie
Practice it inside an adaptive study session. Archie, your Socratic AI tutor, tracks your mastery with Bayesian Knowledge Tracing and schedules the perfect next review.