Index of every page on this site: llms.txt
All skills
Run it yourself

Designs, audits and implements caching for a specific website or app across every layer, including HTTP/browser headers (Cache-Control, ETag, Vary), service workers, CDNs and edge (Cloudflare, Vercel, Netlify, Fastly, CloudFront, Akamai), nginx/Varnish, in-process and Redis/Valkey/Memcached caches, database and ORM caches, framework caching (Next.js use cache/ISR, Nuxt, SvelteKit, Astro, Rails, Django, Laravel, Spring, ASP.NET), CMS, REST/GraphQL APIs, mobile clients, LLM prompt and semantic caching, and CI build caches. Detects the stack, classifies every route, and writes a validated caching plan covering invalidation, stampede protection, cache security and verification. Use when the user mentions caching, stale content, purging, CDN or Redis setup, or when pages are slow, TTFB is high, or origin, database or hosting costs are too high, even if they never say "cache". Not for clearing local package-manager caches or explaining CPU caches.

  • 81 files
  • 630.9 KB
  • MIT
  • Updated 4 weeks ago
  • GitHub
Use this Skill: https://skilld.dev/gh/onlymoein/master-cache-skill/caching-strategy

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesplatformsnetlify.md

≈1.7k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Netlify

Last reviewed: 2026-10-27 · Applies to: Netlify CDN, Functions, Edge Functions, durable cache, Cache API, @netlify/cache, @netlify/plugin-nextjs 5.x

Contents

  • When to read this
  • How to detect
  • Default recipe
  • Rules and gotchas
  • Headers and variants
  • Tags and purge
  • Durable cache and Cache API
  • Framework integration
  • Status headers
  • Version notes
  • Verify
  • Sources

When to read this

When the app deploys to Netlify. Netlify's caching specifics in this file came from Netlify's own agent guidance rather than a public docs page; confirm details against docs.netlify.com before relying on exact limits.

How to detect

netlify.toml, _headers/_redirects files, netlify/functions/ or netlify/edge-functions/, @netlify/* deps, response headers x-nf-request-id, cache-status: "Netlify Edge"; …, server: Netlify.

Default recipe

# Function response cached at the edge, shared across nodes via the durable cache
Cache-Control: public, max-age=0, must-revalidate
Netlify-CDN-Cache-Control: public, durable, s-maxage=3600, stale-while-revalidate=86400
Netlify-Cache-Tag: product:123,all
Netlify-Vary: query=page|sort

netlify.toml example: assets/snippets/cdn/netlify.toml.

Rules and gotchas

  1. Dynamic responses (Functions, Edge Functions, proxies) aren't cached unless headers opt in. Only GET is cached.
  2. Header precedence: Netlify-CDN-Cache-Control (Netlify only) > CDN-Cache-Control > Cache-Control (the latter two pass downstream).
  3. Basic auth on any page disables caching for the entire site.
  4. Static assets are fresh up to a year at the edge and a shorter max-age is ignored; they change only on deploy or purge. Atomic deploys invalidate automatically.
  5. Without Netlify-Vary: query=…, the full query string is the key and utm_*/fbclid fragment the cache.
  6. A URL must return the same Netlify-Vary on every response; the first cached response's instructions win.
  7. Each request may hit a different cache instance: without durable or steady traffic, expect several misses before hits.
  8. Never opt sensitive content out of deploy invalidation (Netlify-Cache-ID); it could stay publicly cached after a fix.
  9. netlify dev doesn't emulate the CDN cache; test on a deploy preview.
  10. Purge rate limit: each tag (or the site) can be purged twice per 5 seconds; beyond that you get 429s. Debounce webhook purges.
  11. Browsers get Cache-Control: public, max-age=0, must-revalidate for static files by default, which is right for index.html and other fixed URLs. Fingerprinted build assets need an explicit Cache-Control: public, max-age=31536000, immutable rule for their path in netlify.toml [[headers]] or _headers. Netlify's own build-asset handling may already add it for some frameworks; check with curl -I.

Headers and variants

Defaults: static Netlify-CDN-Cache-Control: public, s-maxage=31536000, must-revalidate; dynamic Cache-Control: public, max-age=0, must-revalidate.

Netlify-Vary keys on specific parts instead of whole headers:

Netlify-Vary: query=item_id|page, country=es+de|us, cookie=ab_test|is_logged_in, language=en|es+pt, header=Device-Type

You can't vary on Accept*, Cache-Control, Connection, Content-Length, Cookie, Host, If-*, Range, Referer, Upgrade, User-Agent headers directly; use the cookie=/language=/country= forms.

Tags and purge

  • Netlify-Cache-Tag: tag1,tag2 (wins over Cache-Tag, which passes downstream; set both when another CDN in front strips Cache-Tag). Case-insensitive, ≤ 1,024 chars per tag, ≤ 500 tags per response.
  • Purge from code: purgeCache({ tags }) from @netlify/functions (no args = whole site; options tags, deployAlias, domain).
  • Purge API: POST https://api.netlify.com/api/v1/purge with site_id/site_slug and cache_tags. Omitting cache_tags purges the whole site; an empty list purges nothing.
  • No soft purge: purge is a hard purge. Use stale-while-revalidate to soften expiry.

Durable cache and Cache API

  • durable (in Netlify-CDN-Cache-Control, serverless functions only, not Edge Functions): stores responses in a shared durable cache so other edge nodes reuse them instead of invoking the function. Eventually consistent, co-located with the functions region. Next.js runtime ≥ 5.5.0 uses it automatically.
  • Cache API (caches.open/match/put) inside handlers: ≤ 100 lookups and ≤ 20 insertions/deletions per invocation; per region, not replicated; invalidated on redeploy; can't cache 206, Vary: * or non-GET; requires public, 2xx and max-age/s-maxage ≥ 1 s. Deletes are eventually consistent. No request collapsing.
  • @netlify/cache: fetchWithCache(url, opts, { ttl, swr, tags, vary, durable }), cacheHeaders(), getCacheStatus(), needsRevalidation().

Framework integration

  • Next.js: @netlify/plugin-nextjs (v5) supports the Full Route Cache and Data Cache; static page responses are cached at the edge and revalidate by path or tag.
  • Nuxt isr route rules map to Netlify's CDN; Astro's experimental cacheNetlify() sets Netlify-CDN-Cache-Control and Netlify-Cache-Tag with the durable cache.

Status headers

RFC 9211 Cache-Status, e.g. "Netlify Edge"; hit, "Netlify Edge"; hit; fwd=stale (SWR), "Netlify Durable"; fwd=uri-miss; stored=true; ttl=3600.

Version notes

  • On-demand Builders are legacy; use durable + cache headers or framework ISR.
  • Next.js runtime 5.5.0+ uses the durable cache automatically.
<details><summary>Old patterns</summary>
  • On-demand Builders (builder() wrapper) for ISR-like behavior.
  • Relying on Cache-Control alone for function caching (no shared durable cache).
</details>

Verify

curl -s -o /dev/null -D - https://site.netlify.app/api/products | grep -iE 'cache-status|age|cache-control'
curl -X POST https://api.netlify.com/api/v1/purge -H "Authorization: Bearer $NETLIFY_TOKEN" \
  -H 'Content-Type: application/json' -d '{"site_id":"'"$SITE_ID"'","cache_tags":["product:123"]}'

Sources

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 46a6ee6. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 weeks ago.

Activeupdated 4 weeks ago
metadata
{
  "version": "1.1.1",
  "last-reviewed": "2026-10-28"
}
Other metadata
compatibility
Live header probes need network access and user-supplied URLs; every other step runs offline with the Python 3 standard library.

README badge

README badge for onlymoein/master-cache-skill