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.

referenceslayersserverless-edge-data.md

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

Serverless and edge data caching

Last reviewed: 2026-10-27 · Applies to: AWS Lambda, Vercel Functions, Netlify Functions, Cloudflare Workers (KV, Cache API, Workers Caching, Durable Objects, D1, Hyperdrive), Fastly Compute (KV/Config Store), Upstash

When to read this

When code runs in serverless functions or at the edge. In-memory caches there are per execution environment and vanish unpredictably; connection fan-out is the main failure mode.

Default recipe

// Module scope: one client per execution environment, opportunistic L1
import { Redis } from '@upstash/redis'
const redis = Redis.fromEnv()                       // HTTP/REST: no TCP pool to exhaust
const local = new Map<string, { v: unknown; exp: number }>()

export default async function handler(req: Request) {
  const key = 'cfg:v2:flags'
  const hit = local.get(key)
  if (hit && hit.exp > Date.now()) return Response.json(hit.v)
  let v = await redis.get(key)
  if (v === null) { v = await loadFlags(); await redis.set(key, v, { ex: 60 }) }
  local.set(key, { v, exp: Date.now() + 5_000 })
  return Response.json(v)
}

Rules and gotchas

  1. Module-scope L1 is a bonus, never a design assumption. Hit ratio depends on instance reuse and can be near zero at low traffic. Bound it.
  2. Create clients outside the handler; reset on connection errors. Budget connections: max_concurrency × pool_size ≤ maxclients − headroom. 1,000 concurrent invocations hold 1,000 connections.
  3. Edge runtimes can't hold long-lived TCP: use HTTP Redis (Upstash), platform caches, or KV. HTTP costs a few ms per call; pipeline/batch commands.
  4. TCP+TLS+AUTH on cold start adds roughly 20–80 ms; VPC-attached Lambda cold starts add more; ElastiCache is VPC-only.
  5. Eventually consistent stores (Workers KV, Fastly KV, Hyperdrive's query cache) don't give read-your-writes. On the request that just wrote, bypass them (origin or a no-cache config).
  6. Never use KV for counters or anything needing atomic read-modify-write; use Durable Objects, D1 or the origin DB.
  7. Many platform caches are per deploy or per region: expect cold caches after each deploy.

Choosing an edge store

Need Cloudflare Vercel Netlify Fastly
Cache whole responses from compute Workers Caching (read-through, tiered, collapsing) CDN via headers durable cache via headers CDN via headers
Cache a fragment/subrequest Cache API (data-center local, explicit put, no collapsing/tiering) Runtime Cache (getCache(), regional, ≤ 2 MB items, ≤ 128 tags) Cache API / @netlify/cache fetchWithCache (per region) Core cache (not covered here)
Read-mostly config, flags, redirects Workers KV (≈ 60 s propagation; cacheTtl min 30 s) Edge Config (most reads < 15 ms P99) — Config Store (Compute, read-only at edge, ~1 ms)
Durable, eventually consistent KV Workers KV Marketplace Redis (Upstash) — KV Store (recent writes may take ~300 ms to read)
Strong consistency, per-user state Durable Objects, D1 Origin DB Origin DB Origin DB
DB access with pooling/caching Hyperdrive (60 s / 15 s SWR default; no write invalidation) Prisma Accelerate or a pooler Pooler Origin

Platform notes

  • Cloudflare Workers Caching: cache key = entrypoint + path + query (order-sensitive) + Worker version (default) + ctx.props; host not included; zone Cache Rules don't apply; purge via ctx.cache.purge()/invalidate() with Free-tier rate limits. Wrap Durable Objects behind a cached entrypoint (e.g. leaderboard max-age=30, purge on write). Details: references/platforms/cloudflare.md.
  • Vercel Runtime Cache: 'use cache: remote' or fetch with force-cache in Next.js 16 uses it; plain 'use cache' is in-memory per instance. Runtime Cache tags don't apply to ISR pages.
  • Netlify: Cache API limits per invocation (100 lookups, 20 writes), invalidated on redeploy.
  • Lambda/SST: provisioned concurrency or pre-warming for latency-critical cold starts; HTTP Redis avoids VPC attachment.

Verify

  • Log cache hit/miss per invocation with the instance ID; confirm the L1 isn't relied on for correctness.
  • Load test at peak concurrency and watch Redis connected_clients vs maxclients and DB connections.
  • After a write, read through the edge path immediately and confirm the writer sees fresh data.

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