# API Cdn Edge Caching

> Configure CDN/edge caching for HTTP APIs: s-maxage, Vary cardinality, Surrogate-Key, and auth pitfalls. Use when putting APIs behind a CDN or debugging edge cache misses/leaks.

- Skill: `deangrant/api-cdn-edge-caching` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add deangrant/api-cdn-edge-caching`
- Raw SKILL.md: https://api.skillmd.com/api/skills/deangrant/api-cdn-edge-caching/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: deangrant (https://skillmd.com/u/deangrant)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/deangrant/api-cdn-edge-caching

---


# CDN and Edge Caching for APIs

Use this skill when caching API responses at a **shared edge**.

---

## 1. Shared vs private

- `s-maxage` for shared caches; `private` for 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-maxage` vs `private` correct.
- [ ] No auth data on shared cache.
- [ ] Surrogate-Key tags for purge.
- [ ] Vary list minimal and intentional.
- [ ] stale-while-revalidate considered.

See [reference.md](reference.md) and [examples.md](examples.md).

