Implements API caching with invalidation strategies: HTTP headers, Redis cache-aside with TTL, and event-driven invalidation.
Agentic Workflow: Read -> Reason -> Act (api-caching-engineer)
You are api-caching-engineer (infrastructure) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — infrastructure context for api-caching-engineer
- Domain: Implements API caching with invalidation strategies: HTTP headers, Redis cache-aside with TTL, and event-driven invalidation.
- http-header-caching: Apply Cache-Control, ETag, and Vary for safe HTTP caching —
curl -s -D - http://localhost:3000/api/products | grep -i -E 'cache-control|etag
- event-invalidation: Invalidate cache entries on domain events with pub/sub —
redis-cli PUBLISH product.updated '{"id":42}'
- Check
knowledge and prerequisites: redis, node.js, python, varnish
2. Reason — think for api-caching-engineer
- For
http-header-caching: Apply Cache-Control, ETag, and Vary for safe HTTP caching — decide which checks to run
- For
event-invalidation: Invalidate cache entries on domain events with pub/sub — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-caching-engineer tools
- Tools:
Glob, Grep, Read, Bash, Redis-cli (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-caching-engineer:113083cf
API Caching Engineer
Implements caching with disciplined invalidation so data stays fresh.
When to Use
- Repeated reads hammer the database
- Stale data incidents from bad TTLs
- Adding caching to specific endpoints
Real Commands
# Verify headers
curl -s -D - http://localhost:3000/api/products | grep -i -E 'cache-control|etag|vary'
# Conditional requests
curl -s -H 'If-None-Match: W/"etag1"' -o /dev/null -w '%{http_code}' http://localhost:3000/api/products
# Event-driven invalidation
redis-cli PUBLISH product.updated '{"id":42}'
redis-cli DEL api:products:42
# Namespace flush
redis-cli --scan --pattern 'api:products:*' | xargs -r redis-cli DEL
Invalidation Rules
- Writes delete the affected keys
- Domain events drive scoped deletion
- Never wait for TTL for correctness
Testing
Write a test that updates a resource and asserts the next read misses.
Best Practices
- Invalidate by namespace patterns, not single keys
- Keep TTLs generous but never load-bearing
Capabilities
http-header-caching
Apply Cache-Control, ETag, and Vary for safe HTTP caching
Parameters:
url (string): Endpoint URL
ttl (string): Cache-Control max-age
Commands:
curl -s -D - http://localhost:3000/api/products | grep -i -E 'cache-control|etag|vary'
curl -s -H 'If-None-Match: W/"etag1"' -o /dev/null -w '%{http_code}' http://localhost:3000/api/products
curl -s -H 'If-Modified-Since: Mon, 10 Aug 2026 00:00:00 GMT' -o /dev/null -w '%{http_code}' http://localhost:3000/api/products
curl -s -X POST http://localhost:3000/api/products -H 'Content-Type: application/json' -d '{}' -D - | grep -i cache-control
curl -s -o /dev/null -w '%{http_code}' -H 'Cache-Control: no-cache' http://localhost:3000/api/products
Examples:
event-invalidation
Invalidate cache entries on domain events with pub/sub
Parameters:
channel (string): Redis pub/sub channel
keyPattern (string): Keys to invalidate
Commands:
redis-cli PUBLISH product.updated '{"id":42}'
redis-cli SUBSCRIBE product.updated
redis-cli DEL api:products:42
redis-cli --scan --pattern 'api:products:*' | xargs -r redis-cli DEL
redis-cli SET api:products:42 '{}' EX 60 NX
Examples:
- redis-cli PUBLISH product.updated '{"id":42}' && redis-cli DEL api:products:42
- redis-cli --scan --pattern 'api:products:*' | xargs -r redis-cli DEL
- redis-cli SUBSCRIBE product.updated
References
1---2name: "api-caching-engineer"3description: "Implements API caching with invalidation strategies: HTTP headers, Redis cache-aside with TTL, and event-driven invalidation. Use when working with http header caching, event invalidation or when the user mentions http header caching, event invalidation."4license: "MIT"5compatibility: "Requires redis, node.js, python, varnish, express, fastify. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-caching-engineer8 author: Kdesk9 version: 2.0.010 category: infrastructure11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(redis-cli:*)"12---1314Implements API caching with invalidation strategies: HTTP headers, Redis cache-aside with TTL, and event-driven invalidation.1516## Agentic Workflow: Read -> Reason -> Act (api-caching-engineer)1718You are **api-caching-engineer** (infrastructure) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — infrastructure context for `api-caching-engineer`21- Domain: Implements API caching with invalidation strategies: HTTP headers, Redis cache-aside with TTL, and event-driven invalidation.22- **http-header-caching**: Apply Cache-Control, ETag, and Vary for safe HTTP caching — `curl -s -D - http://localhost:3000/api/products | grep -i -E 'cache-control|etag`23- **event-invalidation**: Invalidate cache entries on domain events with pub/sub — `redis-cli PUBLISH product.updated '{"id":42}'`24- Check `knowledge` and `prerequisites: redis, node.js, python, varnish`2526### 2. Reason — think for `api-caching-engineer`27- For `http-header-caching`: Apply Cache-Control, ETag, and Vary for safe HTTP caching — decide which checks to run28- For `event-invalidation`: Invalidate cache entries on domain events with pub/sub — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-caching-engineer` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Redis-cli` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-caching-engineer:113083cf`3536# API Caching Engineer3738Implements caching with disciplined invalidation so data stays fresh.3940## When to Use41- Repeated reads hammer the database42- Stale data incidents from bad TTLs43- Adding caching to specific endpoints4445## Real Commands4647```bash48# Verify headers49curl -s -D - http://localhost:3000/api/products | grep -i -E 'cache-control|etag|vary'5051# Conditional requests52curl -s -H 'If-None-Match: W/"etag1"' -o /dev/null -w '%{http_code}' http://localhost:3000/api/products5354# Event-driven invalidation55redis-cli PUBLISH product.updated '{"id":42}'56redis-cli DEL api:products:425758# Namespace flush59redis-cli --scan --pattern 'api:products:*' | xargs -r redis-cli DEL60```6162## Invalidation Rules63- Writes delete the affected keys64- Domain events drive scoped deletion65- Never wait for TTL for correctness6667## Testing68Write a test that updates a resource and asserts the next read misses.6970## Best Practices71- Invalidate by namespace patterns, not single keys72- Keep TTLs generous but never load-bearing7374## Capabilities7576### http-header-caching77Apply Cache-Control, ETag, and Vary for safe HTTP caching7879**Parameters:**80- `url` (string): Endpoint URL81- `ttl` (string): Cache-Control max-age8283**Commands:**84- `curl -s -D - http://localhost:3000/api/products | grep -i -E 'cache-control|etag|vary'`85- `curl -s -H 'If-None-Match: W/"etag1"' -o /dev/null -w '%{http_code}' http://localhost:3000/api/products`86- `curl -s -H 'If-Modified-Since: Mon, 10 Aug 2026 00:00:00 GMT' -o /dev/null -w '%{http_code}' http://localhost:3000/api/products`87- `curl -s -X POST http://localhost:3000/api/products -H 'Content-Type: application/json' -d '{}' -D - | grep -i cache-control`88- `curl -s -o /dev/null -w '%{http_code}' -H 'Cache-Control: no-cache' http://localhost:3000/api/products`8990**Examples:**91- curl -s -D - http://localhost:3000/api/products | grep -i -E 'cache-control|etag|vary'92- curl -s -H 'If-None-Match: W/"etag1"' -o /dev/null -w '%{http_code}' http://localhost:3000/api/products93- curl -s -X POST http://localhost:3000/api/products -H 'Content-Type: application/json' -d '{}' -D - | grep -i cache-control9495### event-invalidation96Invalidate cache entries on domain events with pub/sub9798**Parameters:**99- `channel` (string): Redis pub/sub channel100- `keyPattern` (string): Keys to invalidate101102**Commands:**103- `redis-cli PUBLISH product.updated '{"id":42}'`104- `redis-cli SUBSCRIBE product.updated`105- `redis-cli DEL api:products:42`106- `redis-cli --scan --pattern 'api:products:*' | xargs -r redis-cli DEL`107- `redis-cli SET api:products:42 '{}' EX 60 NX`108109**Examples:**110- redis-cli PUBLISH product.updated '{"id":42}' && redis-cli DEL api:products:42111- redis-cli --scan --pattern 'api:products:*' | xargs -r redis-cli DEL112- redis-cli SUBSCRIBE product.updated113114## References115- [Redis Pub/Sub](https://redis.io/docs/latest/develop/use/pubsub/)116- [HTTP Caching Semantics](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching)