Design an Application Caching Strategy
Design a complete Redis caching strategy with appropriate patterns, TTL policy, invalidation, and stampede protection.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
You are a systems architect with expertise in caching strategies and application performance optimization. I need to implement a robust caching strategy for my application.
Application context:
- Type: [e.g. high-traffic REST API, B2C web application, data platform]
- Stack: [e.g. Node.js + PostgreSQL, Python + MongoDB]
- Caching solution under consideration: [e.g. Redis 7, Memcached, in-memory cache]
- Current traffic: [e.g. 1,000 requests/minute, peaks at 5,000]
- Performance problem: [e.g. database queries too slow, third-party API rate-limited, expensive computations]
Data candidates for caching:
[list the data types: e.g. user profiles, search results, configurations, sessions, revoked JWT tokens]
Design a complete caching strategy:
- Data analysis: classify each data type by access frequency, modification rate, and recomputation cost to prioritize what deserves to be cached.
- Caching patterns: recommend and implement the appropriate patterns (Cache-Aside, Write-Through, Write-Behind, Read-Through) for each use case.
- Expiration policy (TTL): define appropriate TTLs for each data type with justification.
- Invalidation strategy: how to invalidate the cache when data is updated (key-based invalidation, pattern-based, event-driven).
- Handling cache misses: protection against cache stampede (thundering herd) and cache penetration.
- Distributed cache: considerations for a multi-instance environment (Redis Cluster, serialization).
- Metrics: metrics to monitor (hit rate, miss rate, memory usage, evictions) and alert thresholds.
Personalize this prompt with Léa · AI assistant
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Why this prompt works
This prompt is structured to approach caching as a complete systems engineering problem. The initial analysis by access frequency and recomputation cost is the most important step: caching the wrong data (data that changes constantly or is rarely accessed) is worse than not caching at all because it adds complexity without benefit. Protection against Cache Stampede (thundering herd) is often ignored until the first production incident: when a cache expires, all simultaneous requests hit the database at once, causing exactly the overload you were trying to avoid. This prompt forces anticipation of this scenario. Requesting specific metrics with alert thresholds transforms the design into an observable system: a hit rate below 80% generally indicates a bad TTL policy or overly aggressive invalidation, metrics that allow continuous cache tuning in production.
Use Cases
Expected Output
A complete caching strategy with data analysis, recommended patterns, TTL policy, invalidation strategy, and monitoring metrics.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
Be the first to comment on this prompt.
Glossary Terms
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Improve this prompt with the Optimizer
Analyze the prompt, strengthen the context and get a more precise version.
Claude Prompts
Structure, context and examples to get better answers from Claude.
AI prompts for web developers
Code review and debugging, keeping API keys and secrets out of the prompt.
Security, GDPR & Business Plans
ChatGPT Business, Claude Team, Gemini Workspace and Mistral Vibe compared from vendor sources: training, EU hosting and a GDPR checklist.
Similar Prompts
Task brief for Claude Code: frame a feature end to end
Brief template to delegate a complete feature to Claude Code: goal, starting point, constraints, definition of done, working rules and recap format.
Write a project's CLAUDE.md: the brief Claude Code reads at every session
Turns your project description into a dense CLAUDE.md: commands, structure, conventions, pitfalls, off-limits areas and situations where the agent must ask before acting.
Design a Secure Webhook API
Design a webhook API with event subscriptions, signed deliveries, retry limits, and a delivery log your support team can inspect.
Generate Storybook Stories for UI Components
Generate Storybook stories for a UI component, with visual variants, interactive controls, interaction tests, and MDX documentation.