# Onboarding Guide: How a Request-Caching Layer Works A request cache stores the results of expensive work so that repeat requests can be answered without redoing it. It typically sits between your service and a slower or costlier dependency, such as a database or downstream API. ## The request path 1. **Build a key** from everything that affects the response: resource ID, parameters, API version and, where relevant, tenant or user. Omitting one can serve someone the wrong data. 2. **Look up the key.** On a *hit*, return the stored value. 3. On a *miss*, call the origin, store the result, and return it. This pattern is called *cache-aside*. ## Keeping data fresh - **TTL (time to live):** entries expire after a set period. - **Invalidation:** writes delete or update affected entries. - **Eviction:** when memory fills, the cache discards entries, often the least recently used. Decide how stale each response may safely be *before* choosing a TTL. ## Failure modes - **Stampede:** a popular key expires and many requests hit the origin at once. Coalesce duplicate requests and add random jitter to TTLs. - **Cache outage:** use short timeouts, and limit fallback traffic so the origin survives. - **Repeated "not found" lookups:** consider caching them briefly. ## Cost-aware practice A cache saves money only if the work it avoids costs more than running it. - **Logging:** don't log every lookup or payload. Sample, and give debug logging an automatic expiry. - **Metrics:** track hit rate, latency, evictions and origin load. Tag by route template or cache name, **never** by cache key, user ID or request ID. Each unique tag value can create another billable time series. - **Test clusters:** start with the smallest size that answers your question. Set an owner and teardown time when you create it. ## Before you finish a bootcamp exercise - [ ] Debug logging is off - [ ] No metric tags have unbounded values - [ ] Test clusters and cache instances are deleted - [ ] You've confirmed the deletion --- I included a cost section and cleanup checklist to support your Q3 cloud-spend priority, and used concrete steps because recent cohorts found the architecture overview too abstract. It runs close to 300 words and stays vendor-neutral. You could add your team's actual log expiry, cluster size limits and teardown deadline.