Caching — cache-aside, read/write-through, write-behind, HTTP caching and CDN, TTL and invalidation strategies, stampede protection, cache keys and tenancy, consistency trade-offs, measuring hit ratio. Use when adding or debugging caches (caching, cache invalidation, TTL, CDN, cache stampede, hit ratio).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Caching Strategies?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vectora-os-caching-strategies)
---
name: caching-strategies
description: Caching — cache-aside, read/write-through, write-behind, HTTP caching and CDN, TTL and invalidation strategies, stampede protection, cache keys and tenancy, consistency trade-offs, measuring hit ratio. Use when adding or debugging caches (caching, cache invalidation, TTL, CDN, cache stampede, hit ratio).
metadata:
category: performance
---
# Caching strategies
## Purpose
Use caches to cut latency and load without serving wrong or leaked data.
**Use when:** reads dominate and staleness is tolerable within a bound.
**Not for:** masking slow queries that should be fixed.
## Inputs
- Access patterns, staleness tolerance, data sensitivity.
## Outputs
- Cache design: layer, keys, TTL, invalidation, metrics.
## Read first
- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "caching strategies"` for prior decisions, patterns and anti-patterns.
## Steps
1. **Need.** Measure: hit potential and cost of misses.
Done when benefit is quantified.
2. **Layer.** Choose layer (HTTP/CDN, distributed, in-process).
Done when layer fits staleness and scope.
3. **Keys.** Include tenant and auth scope in keys; never cache across users unintentionally.
Done when key design is reviewed for leaks.
4. **Invalidate.** TTL plus event-driven invalidation; stampede protection.
Done when stale bounds are guaranteed.
## Best practices
- Measure hit ratio and stale reads.
- Request coalescing for hot keys.
## Common mistakes
- Caching personalized responses publicly.
- No invalidation strategy.
## Example
Catalog: CDN with stale-while-revalidate 60s plus purge on `ProductUpdated`; hit ratio 94%.
## Reusable prompt
```text
Apply the Caching strategies skill (.agents/skills/caching-strategies/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Design the cache layer, keys (with tenancy), TTL, invalidation and metrics; quantify the benefit.
Return: Cache design: layer, keys, TTL, invalidation, metrics..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```