beresp.stale_if_error

RTIME, can be read and set, but not unset.

Available infetch

The maximum stale age that is acceptable for a particular object.

However, for each request, req.max_stale_if_error limits the maximum stale age. For example, if beresp.stale_if_error for an object is set to one hour, but req.max_stale_if_error is set to ten minutes, ten minutes is the maximum stale age for that particular request. If beresp.stale_if_error for an object is set to ten minutes, but req.max_stale_if_error is set to one hour, ten minutes is the maximum stale age for that particular request.

By default, the value of beresp.stale_if_error will be parsed from the stale-if-error value in the Surrogate-Control or Cache-Control headers received from the backend.

Try it out

beresp.stale_if_error is used in the following solution recipes, which show real world use cases. Click RUN to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Revalidate stale content with 304 from origin

Allow conditional GET requests to origin with 304 response, even if 'outer' request from browser is not conditional.

Serve stale on origin failure

Deal with all potential scenarios for using stale content to satisfy requests when origin is unhealthy or misbehaving.

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.