Caching Strategy Advisor — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Caching Strategy Advisor (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
This skill analyzes a performance bottleneck, a slow query, or an expensive operation and recommends the right caching strategy for it — which cache layer to use, what TTL to set, how to handle cache invalidation, and what to watch out for. It covers in-memory caches, Redis, HTTP caching headers, CDN caching, and database query caching, and explains the trade-offs of each recommendation.
Use this when you have a slow API, a database that's under heavy read load, a page that's slow to load, or any operation that's expensive and called frequently.
Copy this file to .agents/skills/caching-strategy-advisor/SKILL.md in your project root.
Then ask:
Provide:
Add the instructions below to your .cursorrules or paste them into the Cursor AI pane with the context above.
Provide the operation description and context. Ask Codex to follow the instructions below to produce the caching recommendation.
When asked to advise on a caching strategy, follow these steps:
Ask or infer:
Choose the appropriate layer(s):
In-process / in-memory cache (e.g., a Map or LRU cache in the application itself)
Redis / Memcached (distributed key-value cache)
HTTP response caching (Cache-Control headers)
ETag or Last-Modified for conditional requests.CDN caching (Cloudflare, CloudFront, Fastly)
Database query cache / materialized views
TTL (Time-to-live)
Invalidation strategies:
Always check for:
## Caching Strategy Recommendation
### Problem Summary
[1–2 sentences describing the bottleneck and the key workload characteristics]
### Recommended Strategy
[Which cache layer(s) to use and why]
### Implementation Plan
#### Cache Layer: [Layer name]
- **What to cache**: [The exact query result, API response, computed value]
- **Cache key structure**: `[prefix]:[identifier]` (e.g., `product:list:category:electronics:page:1`)
- **TTL**: [Value and reasoning]
- **Invalidation**: [How and when to invalidate]
- **Storage estimate**: [Approximate size per entry × expected number of entries]
### Code Pattern
[Pseudocode or real code example showing the cache-aside or write-through pattern]
### Risks and Mitigations
| Risk | Mitigation |
|------|-----------|
| [Risk] | [How to address it] |
### Expected Impact
[Estimated reduction in DB load, latency improvement, or throughput increase]
### What NOT to cache
[Any related data that should NOT be cached, and why]Input to Agent:
"Use the Caching Strategy Advisor skill. Our GET /api/products endpoint queries the database for a product catalog (500 products, with category and price info). It's called 2,000 times per minute. Products are updated by staff roughly once per hour. Our stack is Node.js + PostgreSQL + Redis (already available). Stale data for up to 5 minutes is acceptable."Output from Agent:
## Caching Strategy Recommendation
>
### Problem Summary The product catalog is read-heavy (2,000 req/min), changes infrequently (~hourly), and can tolerate up to 5 minutes of staleness. This is an ideal candidate for a Redis cache with a TTL-based expiry.
>
### Recommended Strategy Cache the query result in Redis with a 5-minute TTL. Use a cache-aside pattern: on a cache miss, query PostgreSQL and populate the cache. No event-based invalidation needed given the acceptable staleness window.
>
### Implementation Plan
>
#### Cache Layer: Redis - What to cache: Full serialized response ofGET /api/products(the array of 500 products with category and price) - Cache key:products:catalog:all(if no filtering);products:catalog:category:[slug](if filtered by category) - TTL: 5 minutes (300 seconds) - Invalidation: TTL-only. Optionally: explicitly delete the key after a staff product update for immediate freshness. - Storage estimate: ~500 products × ~500 bytes = ~250KB per cache key — well within Redis limits
>
### Code Pattern ``ts async function getProducts(category?: string): Promise<Product[]> { const cacheKey = category ? products:catalog:category:${category}` : 'products:catalog:all';>
const cached = await redis.get(cacheKey); if (cached) return JSON.parse(cached);
>
const products = await db.query('SELECT * FROM products WHERE ...', [category]); await redis.setex(cacheKey, 300, JSON.stringify(products)); // TTL: 300s return products; } ```
>
### Risks and Mitigations
>
| Risk | Mitigation | |------|-----------| | Cache stampede (all cache keys expire at once) | Add small random jitter to TTL:300 + Math.floor(Math.random() * 30)| | Cold start on deploy | Pre-warm cache on server startup by callinggetProducts()|
>
### Expected Impact DB read load for this endpoint drops by ~98% (cache miss rate will be very low at 2,000 req/min with 5-minute TTL).
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.