Context and memory · about 15 minutes of study

Prompt caching

Prompt caching can reuse computation for a compatible repeated prompt prefix. It is different from storing and returning a previously generated answer.

Before you start: Review Memory first. Python-like examples use variables, lists and functions.

Guided concept walkthrough

Follow the mechanism

Stable prefix

Identify repeated eligible input.

1 / 4

A conceptual animation, not a live model trace. Play advances every five seconds and stops at the final stage.

Start with an everyday explanation

A kitchen can prepare shared ingredients once for several meals. Each new order still needs its own final preparation and checks.

See a concrete example

At assumed rates of 1 per million cached input tokens versus 4 uncached, 10,000 eligible tokens cost 0.01 versus 0.04. This is arithmetic with invented rates, not a provider quote.

A claim to question

Caching does not guarantee the same answer or a universal percentage saving.

Try before revealing the answer

Explain the difference between prompt caching, a KV cache and an application response cache.

Show the worked answer

Prompt caching reuses eligible prompt computation across requests. KV state supports token generation. Response caching reuses an answer and needs its own key, authorization and freshness policy.

Now explain the idea to someone else using your own example. If you cannot explain a stage, revisit it before moving on.

Your explanation and revision notes

Loading local notes…

Read the primary reference

Prompt caching: provider-specific behavior

The explanation and exercises are original teaching material. The linked source provides background; examples and assumed numbers here are not claims about a particular company.