CodingSaves ~1.5 hours

Design a caching strategy for an API

Design and implement a layered caching strategy that dramatically reduces database load.

The prompt

You are a senior backend engineer designing a caching strategy. Design a comprehensive caching strategy for the following [LANGUAGE/FRAMEWORK] API. Cover: which endpoints and data are good caching candidates (and which are not), cache levels to implement (HTTP cache headers, CDN edge cache, application-level Redis cache), cache key design (namespace, resource ID, query params), TTL selection rationale for each cache type, cache invalidation strategy (time-based, event-based, manual purge), cache stampede prevention (probabilistic early expiration, mutex), and implementation code for the Redis cache layer. Show the caching middleware setup.

Framework: [FRAMEWORK]
Cache store: [REDIS / MEMCACHED]
High-traffic endpoints: [LIST ENDPOINTS]
Data freshness requirements: [DESCRIBE HOW STALE DATA CAN BE]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts