caching
Skill1 starsChanged 9 months agoMITView on GitHub
Designs and reviews caching strategies. Covers cache placement, invalidation patterns, TTL design, cache stampede prevention, and common caching anti-patterns. Use when adding caching, debugging stale data, or reviewing cache implementation.
8 other projects use a version of this.
Adopted by
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/termstacktheir own version, first seen Apr 16, 2026
- ffsshhttiikk/opencode-agents-skillstheir own version, first seen Feb 28, 2026
Used with
Projects with it also use observability.
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.
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
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- zebbern/claude-code-guide★ 4.6ksame name
- 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
- zebbern/termstack★ 4same name
- ffsshhttiikk/opencode-agents-skills★ 2same 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 repository48 other files it gives its agents.
- accessibilitySkill
- api-designSkill
- api-integrationSkill
- architectSkill
- async-patternsSkill
- best-practicesSkill
- bugSkill
- buildSkill
- ci-cdSkill
- config-managementSkill
- containerizeSkill
- database-designSkill
- data-modelingSkill
- data-pipelineSkill
- debug-latencySkill
- dependency-updateSkill
- deploySkill
- dev-setupSkill
- docsSkill
- error-handlingSkill
- estimateSkill
- feature-flag-opsSkill
- git-recoverySkill
- i18nSkill
- iacSkill
- incidentSkill
- load-testingSkill
- loggingSkill
- migrateSkill
- monitoringSkill
- observability-debugSkill
- onboardSkill
- perfSkill
- phase-gateSkill
- pr-authorSkill
- qaSkill
- refactorSkill
- reviewSkill
- rollbackSkill
- schema-evolutionSkill
- scope-checkSkill
- security-auditSkill
- state-managementSkill
- tech-debtSkill
- tech-stackSkill
- telemetrySkill
- testingSkill
- workflowSkill
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 5 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Don't cache: when:
- Distinctive: line 53
Pro: Only caches data that's actually requested
- Distinctive: line 66
Con: Write latency higher, caches data that may never be read
- Distinctive: line 100
Must track ALL caches affected by each data change.
- Distinctive: line 111
When a popular cache key expires, hundreds of requests simultaneously hit the source.
“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
Caching
There are only two hard things in computer science: cache invalidation and naming things. This skill covers the first one.
When to Cache
Cache when ALL of these are true:
- Read-heavy: Data is read much more often than written
- Expensive to compute/fetch: Database query, API call, heavy computation
- Tolerant of staleness: It's OK if users see data that's a few seconds/minutes old
- Stable enough: Data doesn't change every request
Don't cache when:
- Data must be real-time (account balance, inventory count at checkout)
- Data changes on every request
- The source is already fast enough
- You can't reason about when the cache is wrong
Cache Placement
User → CDN Cache → Reverse Proxy Cache → App Cache → Database Cache → Database| Layer | What to Cache | TTL | Example |
| Browser | Static assets, API responses | Minutes to forever | Cache-Control: max-age=31536000 for hashed assets |
| CDN | Static files, public API responses | Minutes to hours | CloudFront, Fastly |
| Reverse Proxy | Full page/response cache | Seconds to minutes | Nginx, Varnish |
| Application | Computed results, API responses | Seconds to minutes | Redis, Memcached, in-memory |
| Database | Query results, materialized views | Varies | Query cache, materialized views |
Rule: Cache as close to the user as possible. Each layer closer to the user avoids more work.
Cache Strategies
Cache-Aside (Lazy Loading)
READ:
1. Check cache
2. Cache hit → return cached data
3. Cache miss → fetch from source → write to cache → return
WRITE:
1. Write to source
2. Invalidate cache (delete, don't update)- Pro: Only caches data that's actually requested
- Con: First request always slow (cache miss)
- Best for: Most cases. Default choice.
Write-Through
WRITE:
1. Write to cache AND source simultaneously
READ:
1. Always read from cache (guaranteed fresh)- Pro: Cache always consistent
- Con: Write latency higher, caches data that may never be read
- Best for: Data that's written and immediately re-read
Write-Behind (Write-Back)
WRITE:
1. Write to cache
2. Asynchronously flush to source (batched)
READ:
1. Read from cache- Pro: Very fast writes
- Con: Risk of data loss if cache fails before flush
- Best for: High write throughput, analytics, counters
Invalidation Patterns
TTL (Time-To-Live)
cache.set(key, value, ttl=300) # Expire after 5 minutes- Simplest approach. Data is eventually consistent.
- Choose TTL based on: how stale can users tolerate? How expensive is a miss?
Event-Based Invalidation
# On data change, explicitly delete the cache entry
def update_user(user_id, data):
db.update(user_id, data)
cache.delete(f"user:{user_id}")
cache.delete(f"user_list:page:*") # Related caches too- More complex but fresher data.
- Must track ALL caches affected by each data change.
Versioned Keys
cache_key = f"user:{user_id}:v{user.updated_at}"- Old versions naturally expire. No explicit invalidation needed.
- Cache size grows until old versions TTL out.
Cache Stampede Prevention
When a popular cache key expires, hundreds of requests simultaneously hit the source. Solutions:
Lock / Mutex
# Only one request rebuilds the cache; others wait
if cache.miss(key):
if cache.acquire_lock(key):
value = expensive_query()
cache.set(key, value)
cache.release_lock(key)
else:
wait_for_key(key) # or return staleStale-While-Revalidate
# Serve stale data while one request refreshes in the background
cache.set(key, value, ttl=300, stale_ttl=600)
# Serves stale data for 5 extra minutes while refreshingJittered TTL
# Spread expirations to avoid thundering herd
ttl = base_ttl + random(0, jitter_seconds)Common Anti-Patterns
| Anti-Pattern | Problem | Fix |
| Cache everything | Memory bloat, stale data everywhere | Cache only what's expensive and read-heavy |
| No TTL | Stale data lives forever | Always set a TTL, even if long |
| Cache & update (not invalidate) | Race conditions between concurrent updates | Invalidate (delete) on write, not update |
| Caching errors | Error response served to all users | Only cache successful responses |
| Unbounded cache | Memory grows until OOM | Set max size with eviction policy (LRU) |
| Cache key without version | Deploy new code, old cache format causes errors | Include version/schema in cache keys |
Cache Key Design
{service}:{entity}:{id}:{version}
# Examples
api:user:123:v2
api:user_list:page:1:per:20
api:search:q=shoes:page:1- Deterministic: same input → same key
- Namespaced: no collisions between services
- Inspectable: you can read the key and know what it caches
Review Checklist
- Cache has a TTL (no unbounded caching)
- Cache is invalidated on write (not just TTL-dependent)
- Error responses are not cached
- Cache keys are deterministic and namespaced
- Cache stampede handled for hot keys
- Cache size bounded with eviction policy
- Metrics: hit rate, miss rate, eviction rate
- Fallback works when cache is down (graceful degradation)
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.

