The Read-Only Blogread-only
All posts

Caching Every Request with Redis

Josh · March 19, 2026

Each API endpoint uses a simple cache-aside strategy:

  1. Look for the response in Redis under a stable key.
  2. On a hit, return it immediately — the database is never touched.
  3. On a miss, query Postgres, store the JSON in Redis with a short TTL, and return it.

Because the data only changes when we re-seed, a short time-to-live keeps things fresh while still absorbing the vast majority of traffic in memory.