Caching Best Practices
Define invalidation before caching hot paths. Redis is fast; wrong cache design is slow to debug.
Search across all documentation pages
Define invalidation before caching hot paths. Redis is fast; wrong cache design is slow to debug.
env:service:version:entity:id.redis.quit() on shutdown alongside HTTP and DB pool close.No. Profile first. Cache proven hot reads with clear invalidation.
allkeys-lru on dedicated cache nodes. Avoid OOM crashes without eviction policy.
Read endpoints should fall back to DB when business allows. Rate limits may fail closed.
5-15 minutes common for catalog. Shorter when merchandising demands fresher data.
After bulk deploy or import, warm from worker or lazy on first requests with stampede guard.
Pub/sub channel, short TTL, or event bus message - pick one pattern per entity type.
Use hash tags for multi-key ops. Test failover drills on managed provider.
Mystery keys with no TTL and no owner - KEYS * discovery in incident.
Yes if same TTL/invalidation rules enforced. Wrapper does not remove design duty.
Upstash and similar - watch per-request pricing and latency vs VPC ElastiCache.
Stack versions: This page was written for Node.js 24.18.0 (Active LTS), npm 10+, TypeScript 5.6+, Express 5, Fastify 5, and NestJS 11.
Reviewed by Chris St. John·Last updated Jul 16, 2026