Skip to content
Back to skills

Caching Strategy

ASecurity

Adds caching to expensive operations - Redis, in-memory, HTTP cache headers

  • 10 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 1, 2026
ai-agentsbashreactapiperformance

Works with

  • cli
  • api

Security analysis

A100/100

Scanned June 1, 2026

npx -y skills add berkcangumusisik/claude-code-practices --skill caching-strategy --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Caching Strategy?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Caching Strategy
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/berkcangumusisik-caching-strategy/badge)](https://www.skillsdirectory.com/skills/berkcangumusisik-caching-strategy)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: caching-strategy
description: Adds caching to expensive operations - Redis, in-memory, HTTP cache headers
argument-hint: [file-or-endpoint]
user-invocable: true
allowed-tools: Read Grep Glob Edit
effort: medium
---

## Caching Strategy

Target: **$1** (or analyze top bottlenecks if not specified)

1. Identify cacheable operations:
```bash
grep -rn "db\.\|prisma\.\|fetch\|axios" ${1:-src/} --include="*.ts" | grep -v "test\|spec" | head -20
```

What's cacheable?
- Query results that change infrequently (user profile, product catalog)
- Expensive computations (aggregations, reports)
- External API responses (weather, exchange rates)

What's NOT cacheable?
- User-specific real-time data
- Transactional operations
- Anything that must be consistent

2. Choose caching layer by use case:
   - **Redis**: shared across instances, TTL, pub/sub invalidation
   - **In-memory (`Map`)**: single instance, fastest, lost on restart
   - **HTTP `Cache-Control`**: browser/CDN caching for GET responses
   - **React Query / SWR**: client-side data caching

3. Implement with proper cache keys:
```ts
const cacheKey = `user:${userId}:profile`
const cached = await redis.get(cacheKey)
if (cached) return JSON.parse(cached)

const result = await db.user.findUnique(...)
await redis.set(cacheKey, JSON.stringify(result), 'EX', 300) // 5min TTL
```

4. Add cache invalidation on mutations.

5. Show estimated performance improvement.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…