← All lessons
Day 62 of 90

Caching Strategies for LLM Outputs

7 min read

Key Concepts

  • 1Caching LLM and retrieval outputs cuts cost and latency by reusing prior work, but commerce data's volatility makes naive caching dangerous
  • 2Safe-to-cache vs unsafe: stable content (product descriptions, general answers) caches well; volatile facts (price, stock, personalized results) risk serving stale, wrong data
  • 3Prompt/prefix caching reuses the cost of a shared prompt prefix across calls, a cheap win that doesn't risk staleness because only the model's compute is reused
  • 4Semantic caching (returning a cached answer for a similar-enough query) saves the most but risks subtle mismatches, so it needs careful similarity thresholds and guardrails
  • 5Cache invalidation is the hard problem: price and inventory changes must evict affected cached results, or the agent confidently serves outdated information
  • 6Personalization limits caching: per-user results are less cacheable, so caching often applies to shared, non-personalized layers (catalog facts, common queries)
  • 7The PM tradeoff: aggressive caching maximizes savings but raises staleness risk; the right policy is per-data-type, matching cache TTL to how fast the data changes

Why It Matters for PMs

Cost and latency savings: Caching is one of the biggest levers on CPC and speed, directly improving unit economics when applied safely.
Staleness risk in commerce: Cached prices or stock can serve wrong data — a trust failure. PMs must match caching policy to data volatility, not cache blindly.
Invalidation is the hard part: Correct cache eviction on price/inventory changes is what separates safe caching from confidently-wrong answers.

Test Your Understanding

Question 1 (Multiple Choice)

What kind of content is safest to cache in a commerce agent?

Question 2 (Multiple Choice)

Why is prefix/prompt caching a low-risk win?

Question 3 (Multiple Choice)

What is the hard problem in caching volatile commerce data?

Question 4 (Short Answer)

How would you decide caching TTLs differently for product descriptions vs prices and stock?

Think about your answer before revealing the explanation.

Question 5 (Short Answer)

What are the risks of semantic caching, and how would you mitigate them?

Think about your answer before revealing the explanation.