P
💻DeveloppementAdvancedClaude

Design an Application Caching Strategy

Design a complete Redis caching strategy with appropriate patterns, TTL policy, invalidation, and stampede protection.

Paste in your AI

Adapt this prompt

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:

  1. Data analysis: classify each data type by access frequency, modification rate, and recomputation cost to prioritize what deserves to be cached.
  2. Caching patterns: recommend and implement the appropriate patterns (Cache-Aside, Write-Through, Write-Behind, Read-Through) for each use case.
  3. Expiration policy (TTL): define appropriate TTLs for each data type with justification.
  4. Invalidation strategy: how to invalidate the cache when data is updated (key-based invalidation, pattern-based, event-driven).
  5. Handling cache misses: protection against cache stampede (thundering herd) and cache penetration.
  6. Distributed cache: considerations for a multi-instance environment (Redis Cluster, serialization).
  7. 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

Performance optimization through cachingHigh-traffic system architectureReducing database costs

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 Optimizer

Comments

Be the first to comment on this prompt.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementIntermediateClaude

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.

1681
💻DeveloppementIntermediateClaude

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.

640
💻DeveloppementAdvancedAll AIs

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.

411
💻DeveloppementIntermediateAll AIs

Generate Storybook Stories for UI Components

Generate Storybook stories for a UI component, with visual variants, interactive controls, interaction tests, and MDX documentation.

474