Skip to main content
skill CX Codex

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

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add patricio0312rev/skills --skill caching-cdn-strategy-planner -a claude-code
Open on GitHub

What 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-code

2Manually: put the files in place

~/.claude/skills/caching-cdn-strategy-planner/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/caching-cdn-strategy-planner/

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

Similar skills

SKILL.md skills catalog →

From the same set148

The whole set →
monorepo-ci-optimizer monorepo-ci-optimizer — a CI skill for monorepos: it works out which packages a change touches and runs builds and tests only for those. Useful when every PR runs the whole workspace. CX Codex +1 264installs coverage-strategist The coverage-strategist skill helps set test priorities and coverage goals across a project. Use it when deciding which paths need tests and which code can be left out. CX Codex +1 263installs auth-module-builder auth-module-builder lays out a full authentication module: login and registration routes, JWT signing, bcrypt hashing, Redis sessions and a threat model. Useful when the login flow starts from an empty file. CX Codex +1 263installs kubernetes-manifest-generator kubernetes-manifest-generator produces production-grade Kubernetes YAML manifests with hardening, autoscaling, and networking defaults. Useful when preparing workloads for cluster deployment. CX Codex +1 262installs dependency-doctor dependency-doctor scans your manifests, flags outdated and duplicated packages, known CVEs and risky version pairs, then hands back a report with a step-by-step upgrade plan. CX Codex +1 261installs db-performance-watchlist db-performance-watchlist is a Claude Code skill that tracks PostgreSQL metrics, including slow queries, connection pools, and unused indexes through Prisma. CX Codex +1 260installs api-contract-normalizer The api-contract-normalizer skill aligns API responses across endpoints, covering envelopes, errors, pagination, status codes, and versioning. Use it when API conventions have drifted. CX Codex +1 260installs vscode-rest-client-generator vscode-rest-client-generator generates .http files from Express, Next.js, and Fastify routes for the VS Code REST Client extension. Ideal for testing APIs in the editor without Postman. CX Codex +1 259installs

Project sponsors

Companies that keep this analytics open