Module 4 · What the model can see

Prompt caching, and the ordering it demands

In this lesson

  • 8 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 4 of 9 in this chapter

This chapter’s goalBudget a context window across system prompt, history, retrieved material and output; predict where in a long prompt information is most likely to be missed; and explain why prompt injection is a structural property of the input format rather than a bug awaiting a patch.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

What is being cached

Module two established that attention caches each token’s keys and values so they are not recomputed at every generation step. Prompt caching extends the idea across requests: if two requests begin with the same tokens, the keys and values for that shared prefix are identical, so the second request can start from the stored state instead of recomputing prefill.

Nothing about the model changes. It is the same computation, skipped because the answer is already known.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the AI, Actually Explained exam.

Stuck on something?Ask Anjali, your AI tutor

How to cite: Addaly (2026) ‘Prompt caching, and the ordering it demands’, in How a Language Model Actually Works. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/how-llms-work/prompt-caching (Accessed: 29 November 2026).