caching-cdn-strategy-planner — Claude Code skill for caching
caching-cdn-strategy-planner is a Claude Code skill for planning CDN and server-side caching, response headers, and invalidation. Use it in API design.
MIT 262 installs ★ 64 updated 2026-01-12
npx skills add patricio0312rev/skills --skill caching-cdn-strategy-planner -a claude-codeWhat caching-cdn-strategy-planner does
The skill maps caching across the client, CDN, server, and database. Its CloudFront example sets distinct behavior for static and dynamic API paths, and controls which query strings and headers are forwarded.
For server-side caching, a Redis example checks a key first, then fetches and stores the result with a TTL on a miss. The update flow deletes the Redis key and requests a CloudFront invalidation; API examples also set Cache-Control, ETag, and Last-Modified. The Redis connection reads process.env.REDIS_URL, so that environment variable must be configured for the example to connect.
What it helps with
- plan cache layers from client to database
- set separate TTLs for static and dynamic routes
- clear Redis and CDN entries after a record changes
- choose cache headers for API responses
Example prompts for the agent
- Plan a CloudFront and Redis caching setup for this API.
- Set different TTLs for
/api/static/*and/api/dynamic/*. - Add Redis key deletion and CloudFront invalidation after a user update.
How to install caching-cdn-strategy-planner
1Skills CLI (Vercel)
npx skills add patricio0312rev/skills --skill caching-cdn-strategy-planner -a claude-code2Manually: put the files in place
~/.claude/skills/caching-cdn-strategy-planner/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/caching-cdn-strategy-planner/
1Skills CLI (Vercel)
npx skills add patricio0312rev/skills --skill caching-cdn-strategy-planner -a codex2Manually: put the files in place
.agents/skills/caching-cdn-strategy-planner/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add patricio0312rev/skills --skill caching-cdn-strategy-planner -a cursor2Manually: put the files in place
.cursor/skills/caching-cdn-strategy-planner/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install patricio0312rev/skills performance/caching-cdn-strategy-planner/SKILL.md2Manually: put the files in place
.github/skills/caching-cdn-strategy-planner/SKILL.md1Skills CLI (Vercel)
npx skills add patricio0312rev/skills --skill caching-cdn-strategy-planner -a gemini-cli2Platform CLI
gemini skills install https://github.com/patricio0312rev/skills --path performance/caching-cdn-strategy-plannerManually: put the files in place
.devin/skills/caching-cdn-strategy-planner/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add patricio0312rev/skills --skill caching-cdn-strategy-planner -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about caching-cdn-strategy-planner
How do I install caching-cdn-strategy-planner in Claude Code?
Run npx skills add patricio0312rev/skills --skill caching-cdn-strategy-planner -a claude-code. The skill file is at ~/.claude/skills/caching-cdn-strategy-planner/SKILL.md.
What does caching-cdn-strategy-planner do?
It helps plan CDN and server caching, including expiry rules, response headers, and invalidation. Its examples use CloudFront and Redis.
What does the Redis caching example require?
It creates a Redis client with ioredis and reads the connection string from process.env.REDIS_URL. The update example removes the cached key and requests a CloudFront invalidation.
Source text
SKILL.md · MIT
---
name: caching-cdn-strategy-planner
description: Designs multi-layer caching strategy with edge CDN, server-side caching, cache invalidation, and CDN configuration. Use for "caching strategy", "CDN setup", "cache invalidation", or "performance optimization".
---
# Caching & CDN Strategy Planner
Design effective caching at all layers.
## Caching Layers
```
Client → CDN (Edge) → Server Cache → Database
```
## CDN Configuration (CloudFront)
```typescript
const distribution = {
Origins: [
{
DomainName: "api.example.com",
CustomHeaders: [
{
HeaderName: "X-CDN-Secret",
HeaderValue: process.env.CDN_SECRET,
},
],
},
],
DefaultCacheBehavior: {
ViewerProtocolPolicy: "redirect-to-https",
AllowedMethods: ["GET", "HEAD", "OPTIONS"],
CachedMethods: ["GET", "HEAD"],
Compress: true,
DefaultTTL: 86400, // 1 day
MaxTTL: 31536000, // 1 year
MinTTL: 0,
ForwardedValues: {
QueryString: true,
Cookies: { Forward: "none" },
Headers: ["Accept", "Accept-Encoding"],
},
},
CacheBehaviors: [
{
PathPattern: "/api/static/*",
DefaultTTL: 31536000, // 1 year - never changes
},
{
PathPattern: "/api/dynamic/*",
DefaultTTL: 300, // 5 min - changes frequently
},
],
};
```
## Server-side Caching (Redis)
```typescript
import Redis from 'ioredis';
const redis = new Redis(process.env.REDIS_URL);
async function getCachedOrFetch<T>(
key: string,
fetcher: () => Promise<T>,
ttl: number = 3600
): Promise<T> {
// Try cache
const cached = await redis.get(key);
if (cached) {
return JSON.parse(cached);
}
// Fetch and cache
const data = await fetcher();
await redis.setex(key, ttl, JSON.stringify(data));
return data;
}
// Usage
app.get('/api/user/:id', async (req, res) => {
const user = await getCachedOrFetch(
\`user:\${req.params.id}\`,
() => prisma.user.findUnique({ where: { id: req.params.id } }),
3600
);
res.json(user);
});
```
## Cache Invalidation
```typescript
// Invalidate on update
app.put('/api/user/:id', async (req, res) => {
const user = await prisma.user.update({
where: { id: req.params.id },
data: req.body,
});
// Invalidate cache
await redis.del(\`user:\${req.params.id}\`);
// Invalidate CDN
await cloudfront.createInvalidation({
DistributionId: DISTRIBUTION_ID,
InvalidationBatch: {
Paths: { Items: [\`/api/user/\${req.params.id}\`] },
CallerReference: Date.now().toString(),
},
});
res.json(user);
});
```
## Cache Headers
```typescript
app.get("/api/products", (req, res) => {
res.set({
"Cache-Control": "public, max-age=3600", // Browser + CDN: 1h
ETag: generateETag(products),
"Last-Modified": new Date(products.updatedAt).toUTCString(),
});
res.json(products);
});
app.get("/api/user/profile", (req, res) => {
res.set({
"Cache-Control": "private, no-cache", // No caching (sensitive)
});
res.json(profile);
});
```
## Output Checklist
- [ ] CDN configured
- [ ] Server cache implemented
- [ ] Invalidation strategy
- [ ] Cache headers set
- [ ] Monitoring configured
ENDFILE
© patricio0312rev · MIT · patricio0312rev/skills