For AI engineering
Prompt caching, measured
Send the same long prefix with new questions and read the real cache numbers. Then break the cache on purpose.
What to take away
- Caching is a prefix match: tools, then system, then messages. One changed byte invalidates everything after it.
- Put what never changes first and what changes every turn (time, user input, IDs) last.
- Check usage.cache_read_input_tokens in production. If it stays at zero, something in the prefix is changing.
- Writing to the cache costs a little more than a normal request, so caching pays off from the second hit.
- Caches are per model and expire after about five minutes of no use. Switching model starts cold.