Topic hub
Caching
Cache-aside, invalidation, HTTP caching, CDNs and Redis, plus each framework's caching layers.
Lessons
- Profiling and Caching · PHP 8: Modern PHP Development
Find bottlenecks with profilers and speed up apps with APCu, Redis and HTTP caching. - Caching with Spring's Cache Abstraction · Spring Boot: From Basics to Production
Cache expensive reads with @Cacheable and Redis or Caffeine. - Cache-Aside, Read-Through and Write Patterns · Caching and Performance Engineering
The standard patterns for reading and writing cached data. - The Caching Layers of a Web System · Caching and Performance Engineering
Browser, CDN, reverse proxy, application and database caches — and what belongs where. - HTTP Caching and CDNs · Caching and Performance Engineering
Cache-Control, ETags and edge caching for pages and APIs. - Cache Invalidation and Stampede Protection · Caching and Performance Engineering
Keep caches correct and protect the database when hot keys expire. - Redis in Practice · Caching and Performance Engineering
Data structures, eviction, persistence and pitfalls of running Redis as a cache. - Persisted Queries, Trusted Documents and HTTP Caching · GraphQL in Production
Smaller requests, CDN caching and an allowlist of operations. - Conditional Requests, ETags and Optimistic Concurrency · REST APIs in Depth
Prevent lost updates and save bandwidth with validators. - HTTP Caching for APIs · REST APIs in Depth
Cache-Control, private vs shared caches, CDNs and stale-while-revalidate for API responses. - Cost Control: Prompt Caching, Routing & Budgets · Integrating LLM APIs
Pay for fewer tokens and cheaper tokens. - Caching for Resilience · Resilience Patterns
Serve stale data instead of errors when origins fail. - Cache-Aside in Practice · Database Caching at Scale
The read path, the write path and the details (keys, TTLs, serialization, failures) that decide whether a cache helps or hurts. - The Stale-Set Race · Database Caching at Scale
Why cache-aside can still cache an old value forever after a delete — and how leases, versions and short TTLs fix it. - Cache Avalanches and Cold Starts · Database Caching at Scale
When the whole cache disappears at once — restarts, failovers, flushes — the database must not take the full load. - Cache Stampedes (Dogpiles) · Database Caching at Scale
When a hot key expires, every request misses at once: request coalescing, locks, early refresh and stale-while-revalidate. - Event-Driven Invalidation with Outbox and CDC · Database Caching at Scale
Move invalidation out of request handlers so every writer — including scripts and other services — keeps caches correct. - Two-Tier Caching: In-Process L1 + Redis L2 · Database Caching at Scale
Microsecond reads from local memory without serving stale data for long: invalidation fan-out with pub/sub. - Cache Failover and Lost Invalidations · Database Caching at Scale
Asynchronous Redis replication means a failover can bring back values you already deleted.
Decision guides
- Cache-Aside vs Read-Through vs Write-Through vs Write-Behind
- Rate-Limit Algorithms Compared
- Scaling Reads: Cache, Replicas or Read Models?
- TTL vs Delete-on-Write vs Event-Driven Invalidation
- Where to Store Idempotency Keys
Cookbook recipes
- Cache expensive queries with Redis in PHP · PHP
- Implement rate limiting in a PHP API · PHP
- Rate limit a Spring Boot API with Redis · Spring Boot
- Rate limit FastAPI endpoints with Redis · FastAPI
- Run background jobs from FastAPI with ARQ · FastAPI
- Cache FastAPI responses in Redis · FastAPI
- Build a WebSocket chat endpoint in FastAPI · FastAPI
- Revalidate cached data with tags after a mutation · Next.js
- Rate limit Route Handlers and Server Actions · Next.js
- Pre-render dynamic pages with generateStaticParams and ISR · Next.js
- Rate limit an Express API across instances · Node.js
- Process background jobs with BullMQ · Node.js