Workshop material. This page records an investigation. A proposal here is not, by itself, an adopted Commonplace decision.
Request caching: the production path
A request cache stores the result of an earlier request so equivalent later requests can avoid repeating work. The cache key decides which requests count as equivalent; the cached value and its lifetime decide what answer can be reused and for how long. A hit returns the stored result. A miss runs the normal handler, then may store its result. Treat those as two distinct paths when tracing a request.
Before changing a handler, identify what is cached, how the key is built, when entries expire or are invalidated, and what happens when the cache is unavailable. A key must include every input that can change the response, including relevant identity, authorization scope, and request parameters. If it omits one, callers can receive another request’s result. Do not cache a response whose correctness depends on state that the key and invalidation rules cannot represent.
Caching also changes failure behavior. A timeout or transient failure should not become a successful cached result unless the design explicitly permits it. Retries can repeat handler work after a timeout even when the first attempt completed; use the system’s idempotency rules and verify when cache writes happen. Do not assume a cache hit makes a database operation safe to repeat or skips transaction work without checking the actual call path.
For a production change, trace one cache hit and one miss through handler, database transaction, and response. Confirm whether cache reads or writes occur inside the transaction, and whether a commit or rollback can leave a stale or misleading entry. Preserve existing timeout and retry bounds; retries multiply load during cache outages or miss storms. Review metrics for hit rate, errors, latency, and backend load, and define a rollback plan before rollout.
This guide describes the general request-cache model. The available project sources did not identify a specific cache implementation, so confirm its key, expiry, failure, and transaction behavior in the service before applying these steps.