CDN and Edge Caching for APIs
Use this skill when caching API responses at a shared edge.
1. Shared vs private
s-maxagefor shared caches;privatefor user-specific.- Never put Authorization-bearing personalized bodies on shared caches without
correct keys /
private.
2. Vary discipline
Low-cardinality Vary. High-cardinality Vary (e.g. Authorization, cookies)
defeats edge caching. Prefer cache keys / surrogate keys over wild Vary.
3. Quick checklist
-
s-maxagevsprivatecorrect. - No auth data on shared cache.
- Surrogate-Key tags for purge.
- Vary list minimal and intentional.
- stale-while-revalidate considered.
See reference.md and examples.md.