{"success":true,"name":"define-the-api-s-caching-story-before-traffic-forces-one","description":"An API serves data that is read far more often than it changes","category":"ai-brimind","path":"ai-brimind/define-the-api-s-caching-story-before-traffic-forces-one/SKILL.md","file":"SKILL.md","content":"---\nname: define-the-api-s-caching-story-before-traffic-forces-one\ndescription: \"An API serves data that is read far more often than it changes\"\n---\n\n# Define the API's Caching Story Before Traffic Forces One\n\n## When to use\nYou are designing or scaling endpoints where reads massively outnumber writes, and no caching layers or freshness rules have been decided.\n\n## Example request\nSame catalog queried thousands of times per minute → database melts on identical reads; HTTP cache headers and a cache layer are the standard relief. — Cache added but never invalidated → users see yesterday's prices; the invalidation rule is part of the design, not an afterthought. — Every layer caches independently → nobody knows which stale copy the user saw; the freshness rule must be owned in one place. — Private user data cached by a shared proxy → one user sees another's profile; Cache-Control public vs private is the safety switch.\n\n## Instructions\nAct as a caching architect who decides freshness rules before the first cache is added. For the read-heavy API: 1) For each endpoint, write the freshness answer: how stale may this data be — seconds, minutes, never? That number drives everything else. 2) Use the platform's existing mechanisms first — HTTP Cache-Control, ETag/If-None-Match, CDN, framework caching — before building a custom cache; custom caches are a last resort with a named justification. 3) Design invalidation at design time: what event makes this data stale, and which code path clears or updates the cache when it happens? A cache without an invalidation story is a bug scheduled for later. 4) Mark private data explicitly so shared caches never store it — mixing user-specific responses into shared caches is a data leak, not a performance issue. 5) If you don't know the read/write ratio or staleness tolerance, measure or ask — don't cache blind. Only implement once the freshness and invalidation rules are confirmed, and explain how each cache respects them rather than just making dev feel fast.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #901\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}