esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

What Is Prompt Caching?

How prompt caching reuses the repeated start of a prompt, what it saves on input, when it costs more and what breaks it, for your AI interview.

In short

Prompt caching lets the AI provider keep the processed start of a prompt, so repeated calls reuse it instead of paying full price to read it again. It cuts the cost and time of the input only, and only when the same start comes back before the cache expires.

13 min readIntermediateVery common · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Prompt caching is when the AI provider keeps the part of my prompt that repeats, like the policy pack and the tool list, already processed. The next call reuses it and pays a small read price instead of the full price. It only works when the start of the prompt matches exactly and the call comes back before the cache expires, which on Anthropic is five minutes by default. So I put the stable content first and the changing question last. On Anthropic, a write costs extra, so a prompt that never repeats can cost more.

What is prompt caching, in plain words?

A language model reads the whole prompt before it writes a reply. A prompt is everything sent in one call: the instructions, the tool list, the policy text and the customer's question. The provider charges for reading these input tokens, and a token is a small chunk of text.

Prompt caching is a way for the provider to remember the processed start of a prompt. If the next call begins with exactly the same words, the provider reuses that work and charges less for those tokens. Many real apps send the same big start over and over, so this matters.

Think of a call-centre agent who starts every shift by reading the same 40-page policy binder. A sticky note on the page where they stopped saves time, but only while the binder is unchanged from the front. Caching works like that note, and it breaks as soon as anything near the front changes.

In the bank's support assistant, the policy pack is 12,000 tokens and sits at the top of every call. That repeated block is what caching is built to save money on.

Key words

Prompt prefix
The start of a prompt, read from the top. A cache can only match this start, word for word.
Cache write
The first call that stores a prefix. On Anthropic it costs 25 percent more than the normal input price. Other vendors differ.
Cache read
A later call that finds the same prefix and reuses it at a lower price.
Cache lifetime
How long a stored prefix stays usable. Anthropic's default is five minutes.

How does the cache find a match?

The cache matches from the top. It looks for the longest start of your prompt that the provider has already processed recently. Anthropic describes the matching, and Google describes its discount on matched tokens:

  • “Prompt caching optimizes your API usage by letting the API resume from specific prefixes in your prompts.”

    Anthropic

  • “Implicit caching provides a discount on cached tokens compared to standard input tokens.”

    Google Cloud

Because matching starts at the top, one change near the top breaks the match for everything below it. Tool definitions (the tool list) come first, then the system instructions, then the messages. Editing a tool's description throws away the whole cache.

Stable content first, changing content last

Same every call

Tool list

same functions, same wording

Policy pack

12,000 tokens, identical each call

Changes every call

Current time

new each call, so it sits last

Customer question

the only new text that is read

Model

reuses the front, reads the tail

Cache hit

the new tail is billed at full price

  1. 1The policy pack and tool list match the stored start, so they are reused.
  2. 2The clock and the question are new, so only this tail is read fresh.
  3. 3The matched front is billed at a small read price, not the full price.
Caching matches from the top of the prompt, so the same-every-call content goes first and the changing content goes last. Only the matched front is reused, and the tail is read fresh on every call.

Tip

Asked how caching works? Say it matches from the top, so the stable content goes first and the changing content goes last.

How much does caching save, in numbers?

Anthropic prices caching as multiples of the normal input price. A 5-minute write costs 1.25 times the normal price per token. A read costs 0.1 times the normal price on most models, and 0.05 times on Claude Opus 5.5 and Claude Sonnet 5.5. Here is the bank's case in price units, where 1 unit is one token at the full input price.

Python
# A bank's support bot sends the same 12,000-token policy pack with every customer question.
# Costs are in price units: 1 unit is one token at the full input price.
POLICY_TOKENS = 12_000
CALLS = 100       # questions in one 5-minute window
WRITE = 1.25      # first call: a 5-minute cache write costs 1.25 units per token
READ = 0.10       # later calls: a cache read costs 0.10 units per token (most models)

no_cache = POLICY_TOKENS * CALLS
with_cache = POLICY_TOKENS * WRITE + POLICY_TOKENS * READ * (CALLS - 1)

print(f"Policy pack, no cache: {no_cache:,.0f} units")
print(f"Policy pack, cached:   {with_cache:,.0f} units")
print(f"Saved: {1 - with_cache / no_cache:.0%}")

Output

Policy pack, no cache: 1,200,000 units
Policy pack, cached:   133,800 units
Saved: 89%

A hundred questions cost about 133,800 units with caching, instead of 1,200,000 without it. The first call pays the write premium, and the rest read the pack cheaply. Caching also pays back quickly: on Anthropic, a pack sent only once costs 25 percent more, but by the second call the cached total is already lower.

One cache hit across two calls

Policy pack, written

first call stores it, 1.25x price

Policy pack, read

next call reuses it, a tenth of price

Most of the pack saved

100 calls in 5 minutes

  1. 1The first call pays 25 percent extra to store the policy pack.
  2. 2Each later call finds the same start and reads it back at a much lower price.
The policy pack is stored on the first call and read back on the calls that follow, inside the five-minute lifetime. Only the first call pays the write premium, and each later call reads the same start cheaply.

Caching only touches the input. The answer is still generated fresh at full price, so the saving is smaller when the replies are long.

  • “Pay the model's reduced cached-input rate for reused tokens, discounted up to 95%.”

    OpenAI

The vendors differ in how they switch it on. Anthropic needs an opt-in, a cache_control setting that marks what to cache, while OpenAI and Google turn caching on by default for supported models. The discount and the lifetime depend on the vendor and the model, so I check each vendor's page before I quote a number.

When does caching cost you more?

  • One call only

    The write costs extra

    On Anthropic, a 5-minute write costs 1.25 times the normal price, so a prompt that is sent once and never read again costs more than without caching.

  • Two calls or more

    Paid back on the second call

    The second call reads the stored start at about a tenth of the price, so the extra write is paid back inside the lifetime.

Other vendors differ. OpenAI says its cache-write pricing is not an additive fee, and Google bills cache creation at the standard input token price unless its cache write pricing applies.

The lifetime is the other limit. Anthropic keeps a cache for five minutes by default, and the timer restarts each time the cache is used. A one-hour option exists, but writing to it costs 2 times the normal price. So caching suits bursts of similar calls. A prompt used once a day gains nothing and pays the write price.

What breaks a cache hit?

  1. 1

    A changing value at the top

    A clock, a session ID or a customer name placed above the stable content changes on every call, so nothing below it can match.

  2. 2

    A changed tool list

    Editing a tool's name, description or parameters clears the whole cache, because the tools come first in the order.

  3. 3

    A pause longer than the lifetime

    If the gap between calls is longer than the lifetime, the stored start has expired, and the next call writes it again at the write price.

  4. 4

    A prompt below the minimum length

    Anthropic says shorter prompts cannot be cached, so they are processed without caching and the call still succeeds.

  5. 5

    Calls sent at the same moment

    A cache entry only becomes ready after the first response starts, so parallel calls miss. Send one first, then the rest.

  6. 6

    The fix

    Put the stable content first, keep it word for word, and place the changing part at the end of the prompt.

Here is the cache killer in plain Python. Words stand in for tokens, so the code shows which part of the prompt a cache could reuse.

Python
# The cache can only reuse the start of a prompt that matches an earlier call, word for word.
# Words stand in for tokens here.
POLICY = "Refund policy v7: 30 days with receipt. Card fees are never refunded. Escalate disputes over 500 dollars.".split()

def shared_start(old, new):
    # Count the matching words from the top, stopping at the first difference.
    count = 0
    for a, b in zip(old, new):
        if a != b:
            break
        count += 1
    return count

# Clock first: the match stops at the clock digits, so the policy pack cannot be reused.
call1 = ["Time", "09:14"] + POLICY + ["Question:", "Where is my refund?"]
call2 = ["Time", "09:15"] + POLICY + ["Question:", "Can I get a fee back?"]
print("Clock first, words reused:", shared_start(call1, call2))

# Policy first, clock last: the whole policy pack matches.
call1 = POLICY + ["Question:", "Where is my refund?", "Time", "09:14"]
call2 = POLICY + ["Question:", "Can I get a fee back?", "Time", "09:15"]
print("Policy first, words reused:", shared_start(call1, call2))

Output

Clock first, words reused: 1
Policy first, words reused: 18

What does the interviewer want to hear?

A strong answer covers

  • Caching reuses the processed start of a prompt, matched word for word from the top.
  • It cuts the cost and time of the input only. Output is billed at the usual price.
  • On Anthropic, writes cost more and reads cost much less, so repeated prompts are where it pays.
  • The lifetime is short by default, so it suits bursts of similar calls.
  • Order matters: stable content first, changing content last.
  • Vendors differ: Anthropic opts in, OpenAI and Google turn it on by default, and the numbers depend on the model.

Common traps

  • Trap"Caching makes the whole call cheaper, including the answer."

    BetterIt discounts the repeated input only. The answer is still generated at full price.

  • Trap"Turn caching on and the bill drops."

    BetterOnly if the start repeats, matches exactly and returns within the lifetime. Order the prompt for that.

  • Trap"Put the date and the customer's name at the top for context."

    BetterAnything that changes at the top breaks the match below it. Put changing values last.

Can you spot the cache killer?

Spot the cache killer

Your bank's support bot builds this prompt for every customer. Which version will rarely hit the cache?

Quick check

A bank's assistant sends the same 12,000-token policy pack on every call. Which change gets the most cache hits?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q089How do you order a prompt so caching hits?12 min
  2. Q055What is the KV cache, and why does it speed up generation?12 min
  3. Q324How do you estimate token cost for a feature?11 min
  4. Q325What is semantic caching?Coming soon
  5. Q326Prompt cache vs semantic cache vs KV cache?Coming soon
  6. Q334How do you cut cost on a cloud-hosted LLM workload?Coming soon

Learn it in depth

Last updated on 26 November 2026

Building an assistant that sends the same big prompt on every call?

I design and build AI products and agents, the screens and the system behind them. Book a short call and tell me what you need, including how many calls you expect and how big the repeated part is.