auto-caching
Installation
SKILL.md
Caching — What Claude Gets Wrong
You add caching as a simple if-cached-return-else-fetch pattern. This works for a single user on localhost. In production, 50 concurrent requests all miss simultaneously, all fetch, and you've amplified load instead of reducing it. Then when the API errors, you cache the error for 5 minutes and serve garbage.
The Five Rules
- Stampede protection — concurrent misses for the same key must coalesce into one fetch
- Never cache errors — or cache with very short TTL (5s) as negative cache
- Invalidation strategy — know HOW and WHEN cached data becomes stale
- Stale-while-revalidate — serve slightly stale data while refreshing in background
- Observability — track hit rate, miss rate, evictions, and cache size