Three caches, three uses
- Prompt cache (provider-side) — system prompts, large stable docs, tool definitions. Reduces input cost dramatically.
- Response cache (your side) — for deterministic prompts on identical inputs (rare in chat, common in extraction / classification).
- Semantic cache — match incoming queries to recent similar queries; serve cached response if similarity is high. Most useful in FAQ-shaped traffic.
Tradeoffs
- Prompt cache: cheap, almost free, no quality risk. Default on for stable prefixes.
- Response cache: needs determinism (temperature 0) and stable input hashing.
- Semantic cache: powerful but risky — wrong matches return wrong answers confidently. Set a high similarity threshold and have a fallback.
Invalidation
Caches need a story for invalidation. Prompt cache TTLs are provider-managed (minutes to hours). Response cache invalidates on data updates. Semantic cache invalidates on policy changes. Put invalidation in the same diff as the change that requires it.