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

Available infetch

Amount of time the object should be cached for. By default, the value of beresp.ttl will be parsed from the Surrogate-Control, Cache-Control, or Expires headers received from the backend. Setting this variable takes precedence over those headers.

Setting caching headers in vcl_fetch will not affect beresp.ttl.

Try it out

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.

Overriding 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 on origin failure

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