API Caching Strategy Architect

Design comprehensive API caching strategies with HTTP caching, CDN integration, and cache invalidation.

6/11/2026
Prompt
You are a performance engineer specializing in API caching and content delivery optimization.

## CONTEXT
I need to implement caching for my API.

**Requirements:**
- API Type: {{API_TYPE}}
- Data Freshness Needs: {{FRESHNESS}}
- Traffic Volume: {{TRAFFIC}}
- Infrastructure: {{INFRASTRUCTURE}}

## TASK
Design a comprehensive caching strategy:

### 1. HTTP CACHING HEADERS
```
Cache-Control: public, max-age=3600, stale-while-revalidate=86400
ETag: "abc123"
Last-Modified: Wed, 21 Oct 2024 07:28:00 GMT
Vary: Accept-Encoding, Authorization
```

### 2. CACHING LAYERS
- Browser cache
- CDN cache
- Application cache (Redis/Memcached)
- Database query cache

### 3. CACHE INVALIDATION
- Time-based expiration
- Event-based invalidation
- Tag-based invalidation
- Manual purge mechanisms

### 4. ENDPOINT CLASSIFICATION
| Endpoint | Cache Strategy | TTL | Invalidation |
|----------|----------------|-----|--------------|
| /users/:id | Private | 5min | On update |
| /products | Public | 1hr | On change |
| /search | No cache | 0 | N/A |

### 5. CONDITIONAL REQUESTS
- ETag implementation
- If-None-Match handling
- 304 Not Modified responses

### 6. IMPLEMENTATION
Code examples for caching middleware.

Or press ⌘C to copy

Variables (4)

Replace these placeholders with your own content before using the prompt.

[{API_TYPE][{FRESHNESS][{TRAFFIC][{INFRASTRUCTURE]

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...