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.

referencescmsheadless-cms.md

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

Headless CMS (Sanity, Contentful, Strapi, Payload, others)

Last reviewed: 2026-10-27 · Applies to: Sanity (API CDN, Live Content API), Contentful (CDA/CPA, webhooks), Strapi, Payload, Storyblok, Prismic, Hygraph

Contents

  • When to read this
  • How to detect
  • Default recipe
  • Rules and gotchas
  • Sanity
  • Contentful
  • Strapi and Payload
  • Verify
  • Sources

When to read this

When content comes from a headless CMS and is rendered by a framework (Next.js, Nuxt, Astro, SvelteKit, Remix). The CMS has its own CDN; your framework and CDN add more layers. The plan must say which layer owns freshness and how publish events reach each one.

How to detect

package.json with @sanity/client/next-sanity/sanity, contentful/contentful-management, @strapi/strapi or a Strapi URL env, payload/@payloadcms/*, @storyblok/*, @prismicio/client, graphql-request pointing at hygraph.com; env vars like SANITY_PROJECT_ID, CONTENTFUL_SPACE_ID, CONTENTFUL_PREVIEW_TOKEN.

Default recipe

  1. Tag each fetch by entity (post:{id}, type:post) in the framework cache, with a long TTL backstop.
  2. Publish webhook → route handler that verifies a secret/signature, maps the payload to tags, and calls the framework invalidation (revalidateTag, Nuxt storage removal, CDN purge by tag). Example: assets/snippets/frameworks/nextjs-cms-webhook-route.ts.
  3. Drafts/preview bypass every cache (CMS CDN off, framework cache off, private, no-store).
  4. CDN layer in front of the site purges by the same tags (references/layers/cdn-concepts.md).

Rules and gotchas

  1. Count the layers: CMS CDN → framework data cache → full-route cache → CDN → browser. A publish must clear each one or wait out its TTL; the slowest layer sets real freshness.
  2. Framework revalidation doesn't clear the CMS's own CDN: Next.js revalidate doesn't control Sanity's API CDN, so stale content can be re-fetched right after revalidation. Use the CMS's sync/live features or bypass its CDN for revalidation fetches.
  3. Webhook endpoints must verify a secret or signature and be idempotent; retries and reorderings happen. Rate-limit and log them.
  4. Map references: when a referenced document changes (author, category), invalidate the documents that embed it (tag by referenced IDs or use the CMS's dependency info).
  5. Preview tokens must never reach a cached response or the client bundle.
  6. Scheduled publishing needs the same webhook path (publish events at the scheduled time).

Sanity

  • useCdn: true serves from the API CDN (cached; about 600 s stale-while-revalidate behavior per Sanity docs); useCdn: false for drafts, preview and fetches right after a webhook.
  • Live Content API / Sync Tags: responses carry sync tags you can map to framework cache tags; next-sanity integrates this with defineLive/sanityFetch. Prefer it over hand-rolled webhooks on Next.js.
  • Perspectives: published for production, previewDrafts/drafts for preview (never cached).

Contentful

  • Content Delivery API (cached CDN) for published content; Content Preview API for drafts (never cached).
  • Webhooks on Entry/Asset publish/unpublish; protect with a secret header; map sys.id and content type to tags.
  • Next.js: tag fetches with sys.id, then revalidateTag(tag, 'max') in the webhook handler (Next 16 two-argument form; references/frameworks/nextjs.md).

Strapi and Payload

Self-hosted: you own their response caching. Use lifecycle hooks/webhooks (Strapi webhooks, Payload afterChange hooks) to purge framework and CDN caches by tag. Their REST/GraphQL APIs aren't CDN-cached by default; add a CDN or app cache only for published, public content. Plugin specifics weren't verified in this skill's research.

Verify

# Publish a change, then within the expected propagation time:
curl -s -o /dev/null -D - https://example.com/blog/post-slug | grep -iE 'age|x-cache|cf-cache-status|x-vercel-cache|x-nextjs-cache'
curl -s -X POST https://example.com/api/revalidate -H 'x-webhook-secret: wrong' -o /dev/null -w '%{http_code}\n'   # expect 401

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