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 code examples. Examples apply VCL to real-world use cases and can be deployed as they are, or adapted for your own service. See the full list of code examples for more inspiration.

Click RUN on a sample below to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Serve stale content from cache while origins are offline

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