Caching & Performance
Design Philosophy
- Cache-aside pattern: Check cache first, fallback to DB, populate cache
- Graceful degradation: Redis failure → still works (DB only)
- Rate limiting: Protect expensive endpoints from abuse
- Upstash for Edge: HTTP-based Redis, works in serverless/middleware
- Smart cache bypass: Filtered queries skip cache, hit DB directly
Architecture
┌──────────────┐
│ Request │
└──────┬───────┘
│
▼
┌──────────────────────────────────────┐
│ Has Filters? │
│ (category, sort, page, search) │
└──────┬───────────────────┬───────────┘
│ │
YES NO
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ PostgreSQL │ │ Redis Cache │