StackPractices

caching

Practical resources about caching for software engineers.

38 results

Speeding Up Applications with Caching

Caching is one of the highest-impact optimizations available to engineers. A well-placed cache can reduce database load by orders of magnitude and turn slow endpoints into sub-millisecond responses.

Discover patterns for in-memory caching with Redis, CDN edge caching, cache-aside and write-through strategies, and invalidation approaches. Each recipe discusses consistency trade-offs and provides production-tested configuration examples.

intermediate

CDN Cache Invalidation Strategies and Patterns

Implement CDN cache invalidation using purge APIs, surrogate keys, tag-based invalidation, and...

intermediate

Cache Database Query Results with Redis and Python

Cache expensive database query results in Redis with cache-aside pattern, TTL management, and...

beginner

HTTP Cache-Control Headers for APIs and Static Assets

Set Cache-Control, ETag, and Last-Modified headers to control browser and CDN caching for API...

intermediate

Configure Caffeine Cache in Java with Eviction Policies

Set up Caffeine cache in a Java application with size-based, time-based, and weighted eviction...

intermediate

Use Spring Cache Annotations with Redis Backend

Apply Spring's @Cacheable, @CachePut, and @CacheEvict annotations with a Redis cache manager for...

advanced

Multi-Level Cache with In-Memory L1 and Redis L2

Implement a two-level cache combining in-memory L1 and Redis L2 for low-latency reads with...

intermediate

Cache HTTP Responses with Nginx Reverse Proxy

Configure Nginx as a caching reverse proxy to cache upstream HTTP responses with TTL zones, cache...

intermediate

Implement an LRU Cache in Node.js

Build a least-recently-used cache in Node.js with O(1) get and set operations using a Map-based...

intermediate

Implement Redis Cache Invalidation in Node.js

Invalidate Redis cache entries in Node.js with TTL expiry, explicit deletion, pattern-based...

intermediate

Cache Database Queries with Django Cache Framework

Use Django's built-in cache framework with per-view caching, template fragment caching, and...

intermediate

Cache HTTP Responses with httpx and CacheControl in Python

Cache HTTP responses in Python using httpx with CacheControl for HTTP-compliant caching, ETag...

intermediate

Store User Sessions in Memcached with Python

Use Memcached as a distributed session store in Python web applications with pymemcache, TTL...

python caching sessions distributed-cache
intermediate

Cache Function Results with Redis and TTL in Python

Build a Python decorator that caches function return values in Redis with configurable TTL, key...

intermediate

Implement the Cache-Aside Pattern with Redis

Use the cache-aside pattern to read and write data through Redis, handling cache misses, stale...

advanced

Distributed Locking with Redis and Redlock

Implement distributed locks with Redis for mutual exclusion across processes, using SET NX with TTL...

intermediate

Redis Pub/Sub for Cross-Process Messaging

Use Redis pub/sub channels to broadcast events between processes, handle subscriptions, and...

advanced

Rate Limiting with Redis Token Bucket Algorithm

Implement a distributed token bucket rate limiter using Redis atomic operations for API throttling...

intermediate

Build a Real-Time Leaderboard with Redis Sorted Sets

Use Redis sorted sets to implement real-time leaderboards with rank tracking, score updates, and...

intermediate

Node.js Caching with Redis: Cache-Aside and TTL Patterns

Cache API responses in Node.js with Redis using cache-aside and TTL patterns

intermediate

Embedding Cache Pattern

Cache LLM embeddings to reduce API calls and cost. Store embeddings with a content hash key and...

No results found.