A translation platform processes documents in 40 languages and uses few-shot examples in the system prompt to demonstrate translation style and tone. They currently include 5 examples per language (200 examples × average 150 tokens = 30,000 tokens) in the system prompt for every request regardless of target language. With prompt caching, this entire prompt is cached. However, the cache is invalidated whenever any example changes (e.g., updating French examples invalidates the cache for Spanish requests too). What caching architecture minimizes cache invalidation frequency?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Here's the deal — the problem is that a monolithic prompt creates a single cache dependency — any change invalidates the entire cache for all languages. The optimal architecture separates stable content (universal instructions) from variable content (language-specific examples) and caches only the stable prefix.
Full explanation below image
Full Explanation
The problem is that a monolithic prompt creates a single cache dependency — any change invalidates the entire cache for all languages. The optimal architecture separates stable content (universal instructions) from variable content (language-specific examples) and caches only the stable prefix. The universal 2,000-token prefix is cached and almost never changes. The 750-token language-specific block varies per request but is small (low cost on cache misses). When French examples are updated, only the French-language requests pay cache_write cost for the language block — the universal prefix remains cached for all requests. Option A (monolithic) is the current antipattern. Option C (40 separate cached prompts) is technically valid but operationally complex, and cache storage is maintained per-organization so 40 concurrent cache entries compete for cache capacity. Option D eliminates the cache issue but at the cost of translation quality — few-shot examples materially improve style consistency.