GPT-4o
⚙️ Technical
Advanced
Design a Caching Strategy for Your Application
Design a layered caching strategy that reduces database load, improves response times, and handles cache invalidation correctly.
The Prompt
# Design a Caching Strategy for Your Application You are a senior performance engineer designing a caching strategy for [APPLICATION_NAME]. ## Application Context Stack: [TECH_STACK] Current bottleneck: [PERFORMANCE_BOTTLENECK] Traffic pattern: [TRAFFIC_PATTERN] (steady / spiky / read-heavy / write-heavy) Data freshness requirement: [FRESHNESS_REQUIREMENT] Scale: [SCALE] requests per day ## Cache Layer Design **Layer 1 — In-memory application cache** What to cache: [HIGH_READ_DATA] Cache library for [TECH_STACK]: TTL strategy: Max size and eviction policy: **Layer 2 — Distributed cache (Redis / Memcached)** What to cache: [SHARED_STATE_DATA] Key naming convention: Serialization format: TTL and eviction: **Layer 3 — HTTP caching** Which endpoints benefit from Cache-Control headers? CDN caching rules for [APPLICATION_NAME]: **Layer 4 — Database query cache** Which queries warrant materialized views or query-level caching? ## Cache Invalidation Strategy The hardest part — design the invalidation logic for [APPLICATION_NAME]: - On write: which cache keys must be invalidated? - Time-based expiry: what TTL for each data type? - Event-based invalidation: which events trigger cache busting? - Handling stale reads: is eventual consistency acceptable for [FRESHNESS_REQUIREMENT]? ## Cache Warming How to pre-populate caches after a cold start or deployment for [APPLICATION_NAME]. ## Monitoring Define the cache metrics to track and alert on.
📝 Fill in the blanks
Replace these placeholders with your own content:
[APPLICATION_NAME]
[TECH_STACK]
[PERFORMANCE_BOTTLENECK]
[TRAFFIC_PATTERN]
[FRESHNESS_REQUIREMENT]
[SCALE]
[HIGH_READ_DATA]
[SHARED_STATE_DATA]
How to use this prompt
1
Copy the prompt
Click "Copy Prompt" above to copy the full prompt text to your clipboard.
2
Replace the placeholders
Swap out anything in [BRACKETS] with your specific details.
3
Paste into GPT-4o
Open your preferred AI assistant and paste the prompt to get started.