CClaude Cert Prep
P2Claude Models, Prompting & Context EngineeringConcept

Prompt caching

Also: context caching · prefix caching · cache_control

Reuse a stable, up-front prompt prefix across calls so repeated tokens are cheaper and faster to process.

View .md

Why CCAR-P tests this

The exam checks you know caching requires a stable prefix ordered first and helps cost/latency, not accuracy.

Prompt caching lets Claude store and reuse the processed form of a stable prompt prefix — typically a long system prompt, a document, tool definitions, or few-shot examples — so subsequent requests that share that prefix skip reprocessing it. This cuts latency and the cost of the cached tokens on repeat calls.

The design rule is order matters: put the stable, reusable content first and the variable content (the user's specific question) last. A cache hit requires the prefix to match exactly up to the cache breakpoint, so anything that changes per request must come after the cached segment. Caches are time-limited and evict, so caching helps most when the same prefix is hit repeatedly within a short window.

Caching is a cost and speed optimization. It does not change the answer's quality and is not a way to give the model persistent memory — the cached content still occupies the context window on every call.

Exam trap

Placing variable, per-user content before the stable prefix breaks cache hits; caching also does not improve answer quality or act as long-term memory.

All CCAR-P concepts

Independent, unofficial study material from Claude Cert Prep. Not affiliated with Anthropic.