3개 cache, 3개 use
- Prompt cache (provider-side) — system prompt, 큰 stable doc, tool definition. Input cost dramatically 줄임.
- Response cache (너의 side) — identical input에 deterministic prompt에 (chat에 rare, extraction / classification에 common).
- Semantic cache — 들어오는 query를 최근 비슷한 query에 match; similarity 높으면 cached response serve. FAQ-shaped traffic에 가장 유용.
Tradeoff
- Prompt cache: cheap, 거의 free, quality risk 없음. Stable prefix에 default on.
- Response cache: determinism (temperature 0)과 stable input hashing 필요.
- Semantic cache: powerful한데 risky — wrong match가 confidently wrong 답 return. High similarity threshold set, fallback 가져.
Invalidation
Cache가 invalidation story 필요. Prompt cache TTL이 provider-managed (분~시간). Response cache가 데이터 update에 invalidate. Semantic cache가 policy 변경에 invalidate. 변경 require하는 같은 diff에 invalidation put.