On Sun, Nov 20, 2011 at 4:10 PM, Jo Galara <[email protected]> wrote:

> I got the following setup (on a Debian Squeeze 64-bit machine): Internet
> <-> Varnish <-> Apache
>
> What I want to achieve is that Varnish forwards all requests from the
> Internet to the Apache backend (if its not in the cache), uses the
> headers from the backend to choose whether or not and how long to cache
> the file and then send the file to the browser with the _same_ headers
> it got from the from the backend.
>

In vcl_fetch you have all the headers available with beresp.http.<header>.
You can set the TTL based on a header. For example:

if (beresp.http.X-Cache-Time) {
  beresp.ttl = beresp.http.X-Cache-Time;
  return (deliver);
} else
  # default cache time - 30 minutes
  beresp.ttl = 30m;
}

This way, backend must return the X-Cache-Time with something like "30s",
"1m" or anything varnish understands (no cache at all would be "0s").

If you don't unset the header on vcl_deliver, varnish will deliver the
exact headers received on beresp.

-- 
[]'s
Hugo
www.devin.com.br
_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to