Decide what to cache at the HTTP, CDN, application and database layers, with keys, freshness limits, invalidation triggers and metrics for each data class.
Design a caching plan for the application below. Decide per data class whether to cache it, where, for how long and how it is invalidated. Choose the layer before choosing a product; a Redis-specific design is a separate task. ## Inputs Application and request paths in scope: [APPLICATION] Data classes with read/write frequency and size: [DATA_CHARACTERISTICS] How stale each data class may be, and who would notice: [FRESHNESS_TOLERANCE] Personalized or permission-dependent data: [PRIVATE_DATA] Current infrastructure (CDN, reverse proxy, app runtime, cache servers): [INFRASTRUCTURE] Current latency, load or cost measurements, if any: [MEASUREMENTS] ## Instructions 1. Classify each data class: cacheable in shared caches, cacheable only per user, or not cacheable. 2. Choose the layer for each cacheable class (HTTP Cache-Control at browser/CDN, application cache, database result cache) and explain why. 3. Define cache keys that include every input that changes the result (locale, tenant, user, query parameters, version). 4. Derive each TTL from [FRESHNESS_TOLERANCE], not from a generic default. Pair it with an event-based invalidation when edits must appear sooner. 5. Address stampedes on hot keys (request coalescing, early refresh or TTL jitter) and the behaviour when the cache is unavailable. 6. Define the metrics that show whether the plan works: hit ratio per data class, origin load, staleness incidents. ## Return 1. A table with one row per data class: decision, layer, key format, TTL and its rationale, invalidation trigger, failure behaviour. 2. HTTP caching headers for responses served through shared caches. 3. Implementation sketch for the application-level cache in [INFRASTRUCTURE]. 4. A rollout and measurement plan comparing before and after with [MEASUREMENTS]; if none were supplied, say what to measure first. 5. Risks, including data that must never be cached in shared caches. ## Acceptance checks - Every per-user or permission-dependent response is excluded from shared caches or keyed by user. - Each TTL is justified by the stated staleness tolerance. - No latency or hit-ratio improvement is promised; outcomes are framed as what to measure.
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
Application: news site; pages /articles/{slug}, /home, /me/bookmarks; JSON API /api/articles/{slug}/views
Data: articles (read-heavy, edited a few times after publish), homepage list (changes when an article is published), bookmarks (per user), view counter (written on every view)
Freshness: corrected articles must appear within 1 minute; homepage within 5 minutes; bookmarks immediately for the same user; view counts may lag 10 minutes
Infrastructure: CDN in front of a Node app, one PostgreSQL database, a managed Redis instance
Measurements: none yetA table where article pages are shared-cacheable at the CDN with a short s-maxage plus a purge on edit; the homepage uses a TTL within the 5-minute tolerance plus purge on publish; /me/bookmarks is marked private and never stored in shared caches; view counts are buffered in Redis and flushed to PostgreSQL in batches rather than cached reads; keys include slug and locale; stampede protection is described for the homepage; and the measurement plan starts by recording origin request rate and hit ratio because no baseline exists. Illustrative expectation, not a recorded model run.
Ask questions or share concrete improvements.
No comments yet.
Sign in to join the discussion.
Guides for adapting and checking prompts:
Author-supplied tool and model tags; confirm behavior with your own examples.
Models