Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

Dev guideRecipesAPI ReferenceChangelog
Dev guideRecipesUser GuidesNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Fallback cache Logic

Fallback cache delivers the last successful response when backend fails which preserves continuity.

The fallback cache acts as a secondary caching mechanism that stores successful API responses. When a subsequent request for the same resource fails because of a backend error, the system returns the most recent cached response, if available, instead of failing the request.

How Fallback cache logic works

When the backend returns a successful response, the system stores the response in the fallback cache. Each cached entry includes metadata such as a Last-Modified header, which indicates when the data was last updated.

If a subsequent request to the same resource fails because of a server error or timeout, the system checks the fallback cache and returns a valid cached response when available. If no cached response exists, the system returns the original error response.

The Last-Modified header included in the cached response helps clients determine the freshness of the data. This enables crucial UI strategies to be possible. For example, showing fallback notifications.

Behavior and conditions

  • The system stores only responses that meet internal caching criteria.
  • Responses are not cached if:
    • The request includes the query parameter cache=false.
    • The request includes the header Cache-Control: no-cache.
  • Responses served from the fallback cache are read-only. The system does not let you update or delete while operating in fallback mode.

Benefits of Fallback cache logic

  • Improves reliability during backend outages.
  • Reduces visible service interruptions.
  • Delivers the most recent available data, even if the backend is unavailable.
📘

Note

  • Fallback cache responses are read-only. The system does not let users make updates or deletions while operating in fallback mode.
  • Always validate the Last-Modified timestamp before assuming the returned data is current.
  • Fallback cache should not be used as a substitute for proper error handling or data freshness requirements.

Response example

A cached fallback response includes a Last-Modified header, as shown.

HTTP/1.1 200 OK  
Content-Type: application/json  
Last-Modified: 2025-07-28T10:15:00.000Z  
...