FM-017 Time, State, and API Lifecycle

Stale Cache and Cache-Invalidation Failures

Outdated data served after the underlying record changed — inventory showing stock already sold, profiles showing deleted data.

Failure explanation

An API serves an outdated representation because a cache is not refreshed or invalidated after the underlying resource changes. Staleness may occur in browser caches, CDNs, gateways, application caches, or database replicas. Incorrect Cache-Control, ETag, Vary, or invalidation behavior can cause consumers to see old values or leak one user’s representation to another.

Example

A product’s inventory changes from 5 to 0, but a shared cache continues returning the earlier response with Cache-Control: max-age=3600. Customers continue placing orders for unavailable stock.

How to test

  • Read a resource, update or delete it, then read again through each cache path.
  • Test expiration, invalidation, ETag/If-None-Match, Vary, authorization-sensitive responses, and concurrent updates.
  • Compare cached data with the authoritative state.
  • Verify documented consistency and freshness guarantees.

Expected behavior

Cache directives and invalidation behavior match the resource’s consistency requirements. Private or tenant-specific data is not served from an unsafe shared cache.

Runnable examples

Each example includes a broken server, a fixed server, an OpenAPI spec, and a clrsig scenario that detects the failure.

Learn how to find and fix it