Skip to content
mentoor

Prompt caching

For engineers

Ordering prompts so the stable part is cached, cutting cost and latency, and keeping the cache from silently breaking

See where you stand

110 questions across four stages: Understand, Apply, Solve and Judge.

Try 5 questions

Practice items, not counted towards your mastery. No account needed.

Check yourself · 1 of 5

A request starts with the same 5,000 tokens as a cached request, then adds a new question. What happens to the 5,000 shared tokens?

Choose one answer

Check yourself · 2 of 5

Which part of a request is best placed first, so it can form part of the cached prefix?

Choose one answer

Check yourself · 3 of 5

Where do you find out how many input tokens of a request were served from the cache?

Choose one answer

Check yourself · 4 of 5

Which change to a shared system prompt is most likely to destroy cache hits?

Choose one answer

Check yourself · 5 of 5

Why are agent loops a good fit for prompt caching?

Choose one answer

Topics

  1. How prompt caching reuses a prefix4 min read · Exact-prefix matching, cache writes versus reads, time-to-live and minimum lengths across Claude, OpenAI and Gemini APIs
  2. Ordering requests for cache hits4 min read · Tools, system prompt and documents first; timestamps, user input and per-request data last; where cache breakpoints go
  3. Measuring cache hit rate and savings5 min read · Reading cached-token fields in API usage data, hit rate per route, and the real change in cost and latency
  4. Changes that silently break the cache4 min read · A timestamp in the system prompt, reordered tools, per-user data in the prefix, short time-to-live and edits to earlier history
  5. Prompt caching inside agent loops5 min read · Append-only histories, stable tool lists, and why compaction and context edits reset the cached prefix

Start here

110 questions · last verified 2026-12