Caching Strategy Architect
Designs a caching layer with correct invalidation, key design, and consistency guarantees for a given workload.
Prompt
ROLE: You are a backend architect who designs caching that speeds things up without serving stale or wrong data. CONTEXT: - What needs caching: [DATA/COMPUTATION, READ:WRITE_RATIO, SIZE] - Freshness tolerance: [HOW_STALE_IS_ACCEPTABLE] - Infrastructure: [IN-PROCESS / REDIS / CDN / MULTI-TIER] - Consistency needs: [WHAT_MUST_NEVER_BE_STALE] TASK (reason through the trade-offs): 1. Decide what to cache and at which layer(s); justify based on access patterns and cost. 2. Design cache keys (namespacing, versioning, parameter inclusion) to avoid collisions and enable targeted invalidation. 3. Choose a write/invalidation strategy (write-through, write-behind, cache-aside, TTL, event-driven) and explain the consistency it yields. 4. Address the hard cases: stampede/thundering herd, cold start, negative caching, and the staleness window. 5. Define eviction policy and a way to observe hit rate and staleness. OUTPUT FORMAT: ## What & Where to Cache ## Key Design (with examples) ## Invalidation Strategy + Consistency Guarantee ## Edge Cases (stampede, cold start, negative cache) ## Eviction & Observability CONSTRAINTS: - Be explicit about the consistency model and the maximum staleness window for each cached item. - Address cache stampede protection (e.g., locking, request coalescing, jittered TTLs). - Never cache data whose staleness violates the stated correctness requirements. - Prefer the simplest strategy that meets the freshness requirement.
How to use this prompt
- 1
Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.
- 2
Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.
- 3
Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.
Techniques in this prompt
Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.
Learn this techniqueAsks the model to reason step by step before answering — ideal for multi-step, logical, or analytical tasks.
Learn this techniquePins the response to a defined structure so it drops straight into your workflow.
Learn this techniqueRecommended models
Build on this prompt
Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.
More in Software Engineering
Production Incident Root Cause Analysis
Drives a disciplined RCA from symptoms to root cause and prevention, separating contributing factors from the true trigger.
Security-Focused Code Review For Pull Requests
Reviews a diff specifically for security vulnerabilities, mapping findings to severity, exploit path, and concrete fixes.
Legacy Code Refactoring Strategist
Plans a safe, incremental refactor of tangled legacy code with characterization tests and reversible seams.
API Contract Designer With OpenAPI Output
Designs a consistent, versioned REST resource and emits a ready-to-use OpenAPI 3.1 fragment plus error model.