#caching
17 snippets tagged with #caching
In-Memory Caching with LRU Strategy
Implement LRU cache with TTL expiration, size limits, and cache-aside pattern for Node.js applications.
Best for: API response caching
ETag Caching Middleware
Express middleware that generates ETags and handles 304 Not Modified responses for bandwidth savings.
Best for: API caching
Cached Fetch with Revalidation
Fetch external data in Server Components with time-based revalidation and error boundaries.
Best for: CMS content fetching
Next.js ISR & On-Demand Revalidation
Configure Incremental Static Regeneration with time-based and on-demand revalidation strategies.
Best for: Caching CMS content with periodic refresh
Caching Strategies in Next.js
Master Next.js caching with fetch cache, unstable_cache, revalidatePath, and revalidateTag patterns.
Best for: ISR page caching
Cache Tags and On-Demand Revalidation
Tag cached data with identifiers and revalidate specific cache entries on demand.
Best for: CMS webhooks
Materialized View with Auto-Refresh
Create and maintain materialized views for expensive aggregate queries with concurrent refresh support.
Best for: Dashboard analytics
SQL Materialized View Pattern
Create and manage materialized views for caching expensive queries with refresh strategies.
Best for: Caching expensive analytics queries
Create and Refresh Materialized Views
Use materialized views to cache expensive query results for fast reads.
Best for: Dashboard caching
functools.cache and lru_cache
Memoize expensive function calls with functools.cache and lru_cache for automatic result caching.
Best for: Recursive algorithms
Memoize Functions with lru_cache
Cache expensive function results automatically using functools.lru_cache.
Best for: Recursive algorithms
Semantic Caching Layer for LLM Calls
Cache LLM responses by semantic similarity of prompts to reduce API costs and improve latency.
Best for: Reducing LLM API costs for repeated queries
Batch Process Embeddings Efficiently
Process large datasets of embeddings with batching, caching, and rate limiting.
Best for: Large-scale indexing
Cache Embeddings in Redis
Cache expensive embedding API calls in Redis to avoid redundant computation and reduce costs.
Best for: cost reduction
Prompt Caching with OpenAI API
Reduce costs by up to 50% using OpenAI's automatic prompt caching for repeated context prefixes.
Best for: cost reduction
Redis Cache-Aside Pattern in Python
Implement cache-aside (lazy loading) with Redis and Python to accelerate repeated database queries.
Best for: query caching
Spring Boot Caching with Redis
Add caching to Spring Boot services with @Cacheable, @CacheEvict, TTL configuration, and Redis.
Best for: Reducing database load with application-level caching