# Cache Strategy Architect

> Architects caching systems end to end: CDN, reverse proxy, application cache, and database layers with coherence strategies. Use when working with layer caching, coherence design or when the user mentions layer caching, coherence design.

- Skill: `opknock/cache-strategy-architect` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/cache-strategy-architect`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/cache-strategy-architect/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/cache-strategy-architect

---


Architects caching systems end to end: CDN, reverse proxy, application cache, and database layers with coherence strategies.

## Agentic Workflow: Read -> Reason -> Act (cache-strategy-architect)

You are **cache-strategy-architect** (infrastructure) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — infrastructure context for `cache-strategy-architect`
- Domain: Architects caching systems end to end: CDN, reverse proxy, application cache, and database layers with coherence strategies.
- **layer-caching**: Design and operate CDN and reverse-proxy caching. — `curl -sI http://localhost:80/static/app.js`
- **coherence-design**: Design invalidation and write policies. — `redis-cli publish cache.invalidate "user:123"`
- Check `knowledge` and `prerequisites: redis, memcached, varnish, cdn`

### 2. Reason — think for `cache-strategy-architect`
- For `layer-caching`: Design and operate CDN and reverse-proxy caching. — decide which checks to run
- For `coherence-design`: Design invalidation and write policies. — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `cache-strategy-architect` tools
- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Nginx` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `cache-strategy-architect:f5916021`

# Cache Strategy Architect

Design coherent multi-layer caching.

## When to Use

- Designing cache layout for new or scaling systems
- Debugging stale reads across CDN/proxy/app/db caches
- Choosing TTL, validation, and invalidation strategies

## Layers

1. CDN: static assets, public edge content
2. Reverse proxy (nginx/varnish): shared public responses
3. Application cache (Redis/Memcached): hot data, sessions
4. Database cache: query results, read replicas

## Headers

- Cache-Control: max-age, s-maxage, no-store
- ETag: revalidation token
- Vary: key by Accept-Language, Authorization where needed

## Commands

```bash
# Inspect cache behavior
curl -sI http://localhost:80/static/app.js | grep -i cache
curl -s -o /dev/null -w "%{http_code} %{time_total}" http://localhost:80/api

# Coherence operations
redis-cli publish cache.invalidate "user:123"
redis-cli unlink user:123
redis-cli --scan --pattern "user:*"
redis-cli dbsize

# Proxy reload
nginx -t
nginx -s reload
```

## Best Practices

- Cache public data at the edge; private data in app cache only
- Use ETag revalidation over long TTLs for volatile content
- Invalidate by key pattern after writes, not just by TTL
- Add jitter to TTLs to avoid thundering herd
- Measure hit rates per layer before tuning
- Never cache sensitive responses without no-store

## Capabilities

### layer-caching
Design and operate CDN and reverse-proxy caching.

**Parameters:**
- `url` (string): URL to inspect cache headers for
- `header` (string): HTTP header to inspect (Cache-Control, ETag, Vary)

**Commands:**
- `curl -sI http://localhost:80/static/app.js`
- `curl -s -o /dev/null -w "%{http_code} %{time_total}" http://localhost:80/api`
- `nginx -t`
- `nginx -s reload`

**Examples:**
- curl -sI http://localhost:80/static/app.js | grep -i cache
- curl -s -o /dev/null -w "%{http_code}" -H "Cache-Control: max-age=0" http://localhost:80/api

### coherence-design
Design invalidation and write policies.

**Parameters:**
- `key` (string): Key to invalidate
- `pattern` (string): Key pattern to scan or invalidate

**Commands:**
- `redis-cli publish cache.invalidate "user:123"`
- `redis-cli unlink user:123`
- `redis-cli --scan --pattern "user:*"`
- `redis-cli dbsize`

**Examples:**
- redis-cli unlink "article:*"
- redis-cli publish cache.invalidate "orders:42"

## References
- [HTTP Caching](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching)
- [Redis Patterns](https://redis.io/docs/latest/develop/use/patterns/)

