Unlimited Design & Technology

Reliability and Operations

Choose cache invalidation rules before adding a cache

A cache adds a second place from which customers may receive data. Decide acceptable staleness, identity boundaries, invalidation triggers, and failure behavior before using faster responses as the main acceptance criterion.

UDT InsightsAug 16, 2023
A colleague links cached records to a refresh arrow and the source database. A colleague reviews a clipboard.

A cache can make repeated reads convenient, but it also creates a decision about which version of information a customer sees. Before adding one, name the business data and how long it may remain outdated. A public product description and a customer’s available credit should not inherit the same policy merely because both arrive through an application response.

Define freshness in business language

Ask when an update must become visible and which operation confirms the authoritative value. Some data can tolerate a delay. Other data needs a fresh check at the point of commitment, even if an earlier display uses a cached view. Treat that distinction as a product rule.

For HTTP caching, RFC 9111 distinguishes an unqualified no-cache response directive, which requires validation before reuse, from no-store, which prohibits storage and reuse by compliant caches.[8] These names are not interchangeable. Do not assume an application cache automatically implements HTTP cache rules.

Short expiry limits can increase calls to the source, while long limits can leave customers with old information. Event-driven invalidation adds coordination and needs its own failure handling. Choose according to the harm of stale data and the team’s ability to operate the design.

Start with a narrow data category and measure both correctness and response behavior. If the team cannot explain how an update reaches readers, postpone the cache. A slower but understood path is a better starting point than an unexplained second version of business truth.

Choose the key and the invalidation trigger

Describe what makes two requests eligible to share an entry. Consider authorization scope, language, relevant query inputs, and the version of the underlying data. Recommend reviewing identity boundaries before measuring response speed. An entry shared too broadly is not acceptable merely because it is fast.

Then select how entries stop being reusable: an expiry limit, an explicit update event, a version change, or a combination. Explain what happens when invalidation fails or the source becomes unavailable. Keep the rule narrow enough that the team can test its behavior.

Hypothetical example: a training catalog

In this hypothetical example, a training provider caches public course descriptions. Staff can accept a short delay for wording updates, but seat availability must be checked during enrollment. The design therefore separates the cached description from the commitment decision.

The team tests a course update, a canceled course, and two different account roles. It does not use a faster catalog page as proof that enrollment remains correct. This example illustrates data-specific policy, not a claim that one expiry duration suits every business.

Review correctness before the speed chart

Use representative updates and access patterns in a controlled test. Ask the business owner to approve these decisions.

  • Name the data owner and acceptable staleness boundary.
  • Define the fields that determine entry identity.
  • Choose invalidation triggers and their failure behavior.
  • Verify separation between different authorization scopes.
  • Test the final commitment against the authoritative value.

References

Discuss your next project

Talk with UDT about your needs and the next practical step.

Contact UDT
Zalo