RTIME, can be read and
set, but not
Maximum amount of time for which the object will be considered fresh in the cache. By default, the value of
beresp.ttl will be parsed from the
Expires headers received from the backend. Setting this variable takes precedence over those headers.
Once the TTL is reached, if the object has not been evicted or purged, it will become stale.
beresp.ttl 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.
Override TTLs based on content type
Set TTLs at the edge based on the type of resource. Better done at origin, but this can be a great 'quick fix' or a solution if you don't control the origin.
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.