Cache behavior
A cache stores reusable results for faster retrieval. Specify key, expiry and invalidation; stale data may be acceptable for a catalog but dangerous for authorization decisions. Cache product p42 for 60 seconds and invalidate after a price update. A stale description may be tolerable; an authorization decision needs stricter freshness and should not share the same cache policy.
Cache product p42 for 60 seconds and invalidate after a price update. A stale description may be tolerable; an authorization decision needs stricter freshness and should not share the same cache policy.
A cache key identifies a reusable result; time-to-live limits freshness; invalidation removes a result before normal expiry. Imagine a search result depends on query, locale and permissions, but the key includes only the query. Users can receive wrong-language or unauthorized results even while the hit ratio looks excellent. Enumerate every input that changes the response, then decide which belongs in the key and which makes caching unsafe. Write behavior for misses and origin failures, not only hits. Updates must either invalidate affected entries or accept a defined stale window. Caching reduces repeated work but adds another data lifecycle. Choose freshness from the user contract and sensitivity of the decision, then monitor correctness as well as latency improvement. Test an identity-changing request explicitly.
A stale description may be tolerable; an authorization decision needs stricter freshness and should not share the same cache policy.
Authorization responses can safely share the same public cache key.