Prompt caching
A chat sends the whole conversation again every turn. If the beginning of the new request is identical to the previous one, the model can reuse the work it already did on that beginning instead of reading it again.
Three turns of a chat. Lit cells were reused from the cache, grey cells had to be computed. Sizes are illustrative.
- reused from the cache
- computed again
The model computed 24 of 54 tokens; the rest came from the cache.
The picture and its numbers are illustrative.
The takeaway
Reuse stops at the first token that changed. So put what never changes at the start and what changes at the end: one edited word near the top throws away the cache for everything after it.
What the lab knows
On this lab's benchmark an 8k-token prompt takes 0.69 s to the first token cold and 0.11 s when the prefix is cached (Gemma 4 E4B). measured here