caching
Skill4.6k starsChanged 10 months agoMITView on GitHub
Caching strategies — invalidation, TTL guidelines, cache keys, cache layers, and when not to cache. Use when implementing or reviewing caching logic.
- Reads credentials
8 other projects use a version of this, 1 of them edited.
Trending
Steady talk.thin dataabout the whole repository
Most recently taken up by
- nahid-sparktales/agent-dispatchertheir own version, first seen Sep 21, 2026
- codewithmukesh/dotnet-claude-kittheir own version, first seen Jul 22, 2026
- nimadorostkar/Claude-Skills-collectiontheir own version, first seen Jul 14, 2026
- proyecto26/system-design-skillstheir own version, first seen Jun 2, 2026
- zebbern/termstackedited, first seen Apr 16, 2026
- pvnarp/agent-skillstheir own version, first seen Mar 13, 2026
Who's talking about zebbern/claude-code-guide
- @tom-doerr.bsky.social“https://github.com/zebbern/claude-code-guide”Bluesky · Jun 10, 2026 · 2 likes
- A Hacker News story“Claude Code Guide”Hacker News · Jul 1, 2025 · 2 points
- @tom-doerr.bsky.social“https://github.com/zebbern/claude-code-guide”Bluesky · Apr 4, 2026 · 1 likes
- coderPerseus/blog“使用两个月的 Claude Code ,总结下我的最佳实践”GitHub · Jul 20, 2025 · 1 reactions
- sudosubin/agents.nix“agent-skills.github.zebbern.claude-code-guide: init at 0-unstable-2026-05-31”GitHub · Oct 3, 2026
The biggest 5 of 8 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 8
Talked about on GitHub, Bluesky and Hacker News (8 times).
On GitHub · 5
- Jul 20, 2025使用两个月的 Claude Code ,总结下我的最佳实践 — coderPerseus/blog1 reaction · 1 comment
- Oct 3, 2026agent-skills.github.zebbern.claude-code-guide: init at 0-unstable-2026-05-31 — sudosubin/agents.nix0 reactions
- Apr 13, 2026Audit candidate: zebbern/claude-code-guide — xiaolai/nlpm0 reactions · 3 comments
- Apr 6, 2026Audit candidate: zebbern/claude-code-guide — xiaolai/nlpm0 reactions · 1 comment
- Nov 23, 2025AI 相关调研 — wenxueliu/cognitive_center0 reactions · 5 comments
On Bluesky · 2
- Jun 10, 2026https://github.com/zebbern/claude-code-guide — @tom-doerr.bsky.social2 likes and reposts
- Apr 4, 2026https://github.com/zebbern/claude-code-guide — @tom-doerr.bsky.social1 likes and repost
On Hacker News · 1
- Jul 1, 2025Claude Code Guide2 points
Used with
Projects with it also use ci-cd, observability and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 3 projects that use this
OpenAISkillobservability
Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.
Also in 3 projects that use this
ElasticSkillaccessibility
Accessibility guidance for Kibana. Use this skill when working with or reviewing EUI components, resolving a11y-related (@elastic/eui) ESLint issues, and ensuring proper use of ARIA attributes, focus management, keyboard interactions, and accessible naming conventions.
Also in 3 projects that use this
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- zebbern/termstack★ 497% same
Wrote their own version · 7
- codewithmukesh/dotnet-claude-kit★ 750same name
- proyecto26/system-design-skills★ 85same name
- nahid-sparktales/agent-dispatcher★ 59same name
- nimadorostkar/Claude-Skills-collection★ 28same name
- wpank/ai★ 11same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
- pvnarp/agent-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository80 other files it gives its agents.
- skills/composition-patterns/AGENTS.mdAGENTS.md
- skills/react-best-practices/AGENTS.mdAGENTS.md
- academic-paper-reviewerSkill
- active-directory-attacksSkill
- api-fuzzing-bug-bountySkill
- api-shape-explorerSkill
- audit-flowSkill
- authentication-patternsSkill
- aws-penetration-testingSkill
- broken-authenticationSkill
- burp-suite-testingSkill
- chart-imageSkill
- cloud-penetration-testingSkill
- code-documenterSkill
- code-to-diagramSkill
- code-vuln-auditSkill
- vercel-composition-patternsSkill
- cross-examineSkill
- cv-tailorSkill
- database-optimizerSkill
- database-scoutSkill
- dataset-quality-auditSkill
- data-viz-rendererSkill
- deep-module-refactorSkill
- design-system-builderSkill
- dev-guide-generatorSkill
- ethical-hacking-methodologySkill
- file-path-traversalSkill
- html-injection-testingSkill
- http-load-profilerSkill
- idor-testingSkill
- linux-privilege-escalationSkill
- linux-shell-scriptingSkill
- localization-toolkitSkill
- log-error-digestSkill
- metasploit-frameworkSkill
- network-101Skill
- nextjs-developerSkill
- pdfSkill
- pentest-checklistSkill
- pentest-commandsSkill
- pipeline-blueprintSkill
- playwright-ciSkill
- playwright-coreSkill
- playwright-migrationSkill
- playwright-cliSkill
- playwright-pomSkill
- playwright-skillSkill
- privilege-escalation-methodsSkill
- project-sizing-guideSkill
- r2-uploadSkill
- r3f-animationSkill
- r3f-best-practicesSkill
- vercel-react-best-practicesSkill
- red-team-toolsSkill
- regression-modelerSkill
- regulatory-audit-generatorSkill
- repo-auditSkill
- route-to-openapiSkill
- scanning-toolsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 9 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
When implementing a cache layer (in-memory, Redis, CDN) for an API or service.
- Distinctive: line 8
When choosing TTL values or invalidation strategies for cached data.
- Distinctive: line 9
When designing cache key schemas to avoid collisions or stale-data bugs.
- Distinctive: line 10
When reviewing code that reads from or writes to any cache.
- Distinctive: line 11
When debugging stale data, cache stampedes, or inconsistent responses.
- Very specific: line 12
When configuring TanStack Query staleTime/gcTime for client-side caching.
- Distinctive: line 150
Instead: define explicit invalidation (event-driven on write, or bounded TTL) for every cache key.
- Distinctive: line 153
Instead: match TTL to data change frequency — seconds for prices, minutes for profiles, hours for configs.
- Very specific: line 156
Instead: include every parameter that affects the result: products:list:page=2:locale=en.
- Distinctive: line 159
Instead: skip caching on failure, or use a very short TTL (5-10 seconds) to allow fast retry.
- Distinctive: line 162
Instead: use stale-while-revalidate, jittered TTLs, or a mutex lock to let one instance refresh.
“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
WHEN_TO_USE
- When implementing a cache layer (in-memory, Redis, CDN) for an API or service.
- When choosing TTL values or invalidation strategies for cached data.
- When designing cache key schemas to avoid collisions or stale-data bugs.
- When reviewing code that reads from or writes to any cache.
- When debugging stale data, cache stampedes, or inconsistent responses.
- When configuring TanStack Query
staleTime/gcTimefor client-side caching.
INVALIDATION
- [P0-MUST] Define an invalidation strategy for every cache. Stale data is worse than no cache.
- [P0-MUST] Invalidate caches when the underlying data changes — do not rely solely on TTL expiry.
- [P1-SHOULD] Prefer event-driven invalidation (on write/update/delete) over time-based expiry alone.
- [P1-SHOULD] Use cache versioning (include a version key) when data schemas change.
TTL_GUIDELINES
- [P1-SHOULD] Set TTLs based on data volatility: static config (hours/days), user profiles (minutes), real-time data (seconds or no cache).
- [P1-SHOULD] Use stale-while-revalidate: serve stale data immediately while refreshing in the background.
- [P2-MAY] Use shorter TTLs in development and longer TTLs in production.
CACHE_KEYS
- [P0-MUST] Include all query parameters that affect the result in the cache key.
- [P1-SHOULD] Use a consistent key format:
<entity>:<id>:<variant>(e.g.,user:123:profile,products:list:page=2). - [P1-SHOULD] Namespace keys by service or module to prevent collisions.
- [P2-MAY] Hash long or complex keys to keep storage efficient.
CACHE_LAYERS
- [P1-SHOULD] Use the appropriate cache layer for the use case:
| Layer | Best For | TTL Range |
| In-memory (Map, LRU) | Hot data, single-instance apps | Seconds to minutes |
| Redis / Memcached | Shared cache across instances, sessions | Minutes to hours |
| CDN / Edge | Static assets, public API responses | Hours to days |
| HTTP cache headers | Browser caching, API responses | Varies by resource |
- [P1-SHOULD] Layer caches: check memory → Redis → origin. Write-through on miss.
WHEN_NOT_TO_CACHE
- [P0-MUST] Do not cache user-specific sensitive data (auth tokens, payment info) in shared caches.
- [P1-SHOULD] Do not cache rapidly changing data where staleness causes incorrect behavior (inventory counts, real-time pricing).
- [P1-SHOULD] Do not cache error responses — use short TTL or skip caching on failure.
- [P2-MAY] Avoid caching when the computation is cheap and the data set is small.
CODE_EXAMPLES
In-memory LRU cache with TTL
const cache = new Map<string, { value: unknown; expires: number }>();
const MAX_SIZE = 500;
export function getOrSet<T>(key: string, ttlMs: number, compute: () => T): T {
const entry = cache.get(key);
if (entry && entry.expires > Date.now()) return entry.value as T;
const value = compute();
if (cache.size >= MAX_SIZE) {
// Evict oldest entry (first inserted)
const oldest = cache.keys().next().value!;
cache.delete(oldest);
}
cache.set(key, { value, expires: Date.now() + ttlMs });
return value;
}Redis stale-while-revalidate with ioredis
import Redis from "ioredis";
const redis = new Redis(process.env.REDIS_URL);
export async function swr<T>(
key: string,
freshSec: number,
staleSec: number,
fetcher: () => Promise<T>,
): Promise<T> {
const raw = await redis.get(key);
if (raw) {
const { value, createdAt } = JSON.parse(raw) as { value: T; createdAt: number };
const ageMs = Date.now() - createdAt;
if (ageMs < freshSec * 1000) return value; // Fresh — return immediately
if (ageMs < staleSec * 1000) {
// Stale — return cached, refresh in background
fetcher().then((v) =>
redis.set(key, JSON.stringify({ value: v, createdAt: Date.now() }), "EX", staleSec),
);
return value;
}
}
const value = await fetcher();
await redis.set(key, JSON.stringify({ value, createdAt: Date.now() }), "EX", staleSec);
return value;
}HTTP cache headers in Express/Hono
// Immutable assets (hashed filenames)
app.use("/assets", (_, res, next) => {
res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
next();
});
// API responses — short cache with revalidation
app.get("/api/products", (_, res) => {
res.setHeader("Cache-Control", "public, max-age=60, stale-while-revalidate=300");
res.json(products);
});TanStack Query cache configuration
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 5 * 60 * 1000, // Data fresh for 5 minutes
gcTime: 30 * 60 * 1000, // Garbage-collect after 30 minutes
retry: 2,
refetchOnWindowFocus: false,
},
},
});
// Usage in a component
const { data } = useQuery({
queryKey: ["products", { page, category }], // Cache key includes params
queryFn: () => fetchProducts({ page, category }),
});ANTI_PATTERNS
- Cache-and-forget — Caching data with no invalidation strategy. Data goes stale permanently.
- Instead: define explicit invalidation (event-driven on write, or bounded TTL) for every cache key.
- Uniform TTL — Using the same TTL (e.g., 1 hour) for all data regardless of volatility.
- Instead: match TTL to data change frequency — seconds for prices, minutes for profiles, hours for configs.
- Missing key parameters — Cache key omits user ID, locale, or query params, serving wrong data.
- Instead: include every parameter that affects the result:
products:list:page=2:locale=en.
- Instead: include every parameter that affects the result:
- Caching errors — Storing error responses (500s, timeouts) with long TTLs.
- Instead: skip caching on failure, or use a very short TTL (5-10 seconds) to allow fast retry.
- Cache stampede — All instances hit the origin simultaneously when a popular key expires.
- Instead: use stale-while-revalidate, jittered TTLs, or a mutex lock to let one instance refresh.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

