StackPractices

Tag: caching

Browse 48 practical software engineering resources tagged with "caching". Discover code recipes, design patterns, documentation templates, and in-depth guides to help you build, deploy, and maintain production-ready solutions involving caching. Each resource is written for engineers who ship real systems, with copy-paste examples and practical trade-offs.

Caching Strategies and In-Memory Data

Caching is one of the most effective ways to improve performance and reduce load on backends. The challenge is choosing the right strategy, invalidation policy, and consistency model for each use case.

The resources below cover Redis, CDN caching, browser caches, cache-aside, write-through, write-behind, and invalidation patterns. Each recipe explains when and how to cache without introducing subtle bugs.

Every resource includes clear explanations, copy-paste code, and practical warnings. Use them to make informed decisions, avoid production pitfalls, and speed up your delivery. If you are just getting started, read the beginner-friendly articles first; if you are experienced, jump straight to the advanced patterns and architecture guides. New resources are added regularly, so bookmark this page and check back for the latest patterns.

Design a Scalable API Gateway for Microservices

Build an API gateway that routes requests, handles authentication, rate limiting, caching, and...

Cache Database Query Results with Redis and Python

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

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...

Use Spring Cache Annotations with Redis Backend

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

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...

Cache HTTP Responses with Nginx Reverse Proxy

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

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...

Implement Redis Cache Invalidation in Node.js

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

Cache HTTP Responses with httpx and CacheControl in Python

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

Store User Sessions in Memcached with Python

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

Cache Function Results with Redis and TTL in Python

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

Implement the Cache-Aside Pattern with Redis

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

Caching & Memoization in Python, JavaScript, and Java

How to cache expensive computations and API responses using in-memory LRU, TTL, and distributed...

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

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

JavaScript LocalStorage with TTL Expiration

Store data with TTL expiration in browser localStorage

JavaScript Service Worker Offline Caching for PWA

Cache assets for offline PWA support with Service Workers and Cache API

Implement Cache Invalidation Strategies

How to keep caches consistent with databases using TTL, write-through, write-behind, and...

Caching Strategies

Implement useful caching strategies for databases, APIs, and frontends using Redis, CDNs, and...

Embedding Cache Pattern

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

Cache-Aside Pattern

Load data into the cache on demand from the backing store. A caching pattern that gives the...