W3cubDocs

/Varnish

Altering the backend response

Here we override the TTL of a object coming from the backend if it matches certain criteria:

sub vcl_backend_response {
   if (bereq.url ~ "\.(png|gif|jpg)$") {
     unset beresp.http.set-cookie;
     set beresp.ttl = 1h;
  }
}

We also remove any Set-Cookie headers in order to avoid creation of a hit-for-miss object. See Actions.

Copyright © 2006 Verdens Gang AS
Copyright © 2006–2020 Varnish Software AS
Licensed under the BSD-2-Clause License.
https://varnish-cache.org/docs/6.5/users-guide/vcl-example-manipulating-responses.html