Caching/Headers question
Hugo Cisneiros (Eitch)
hugo.cisneiros at gmail.com
Mon Nov 21 15:54:44 CET 2011
On Sun, Nov 20, 2011 at 4:10 PM, Jo Galara <jogalara at gmail.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20111121/e8dc15f7/attachment-0003.html>
More information about the varnish-misc
mailing list