Prompt caching in Claude explained simply
Prompt caching means: βDonβt make Claude read the same big instructions over and over again.β
Imagine you have a 50-page instruction manual for your AI assistant.
Every time you ask Claude something, normally it has to process that manual again:
π 50-page instructions + βWhat is the answer to this question?β
If you ask 100 questions, Claude repeatedly processes those same instructions.
Prompt caching lets Claude temporarily remember that repeated part.
So the next request becomes more like:
β‘ βUse the instructions you already processed + here is my new question.β
This can make requests faster and cheaper. (Claude)
A real-world example
Suppose you're building a customer-support AI.
You always send:
You are a customer support agent.
Here are our company policies...
[20,000 tokens of policies]
Here are 50 example conversations...
[30,000 tokens of examples]
Now answer this customer's question:
"Where is my order?"
The company policies + examples don't change very often.
So you can cache them.
Then the next customer asks:
βCan I return this product?β
Claude can reuse the cached policies and examples instead of processing all 50,000 tokens from scratch.
That's where the savings come from.
How long does Claude remember it?
By default, the cache lasts 5 minutes.
If the cached information is used again, the cache is refreshed. Anthropic also offers a 1-hour cache, which costs more. (Claude)
So think of it as a temporary memory, not permanent memory.
What does cache_control mean?
You'll see this in the code:
cache_control={"type": "ephemeral"}
Don't let the terminology scare you.
It basically tells Claude:
βYou can temporarily cache this part of my prompt.β
Anthropic currently provides two approaches:
- Automatic caching β easiest; Claude manages the cache location for you.
- Explicit caching β you tell Claude exactly which part should be cached. (Claude)
For beginners, start with automatic caching.
When should you use prompt caching?
Prompt caching is especially useful when you repeatedly send large amounts of the same information, such as:
- π Large documents
- π Long system instructions
- π§βπ» Coding guidelines
- π οΈ Tool definitions
- π¬ Long conversations
- π Lots of examples
- π’ Company policies or knowledge
If your prompt is tiny and changes completely every time, caching probably won't help much. (Claude)
The most important idea
Think of your prompt as:
Stable information β Changing information
For example:
[Company policies]
[Product documentation]
[Instructions]
[Examples]
-------------------
[Customer's new question]
You want to cache the top/stable part.
The customer's question can change every time.
That's the basic idea behind prompt caching.
One important detail
Caching isn't automatically free.
There is a small cost when Claude creates the cache, but reading from an existing cache is much cheaper than processing the same input normally. Anthropic currently lists cache reads at 0.1Γ the base input-token price, while creating a 5-minute cache costs 1.25Γ the base input price. (Claude)
So prompt caching is most valuable when you reuse the same large prompt repeatedly.
In one sentence
Prompt caching is a way to temporarily reuse the expensive, repetitive part of your prompt instead of making Claude process it from scratch every time.