Setting default_ttl in vcl file

Steve Scally steve at kcilink.com
Wed Oct 3 23:02:21 CEST 2007


Hello,

I have just started to use varnish and was looking into the default  
cache time of an object / item, etc.  I know the default_ttl is 120  
seconds and I was looking to change that to 3600 seconds.  From the  
documentation and previous mail archives I have found three ways to  
set this. Two ways are through the rc.d and rc.conf files and the  
last is through the vcl.

A. /usr/local/etc/rc.d/varnishd file

Create a variable called varnishd_ttl and set it to 3600.
: ${varnishd_ttl="3600"}

Edit varnishd_flags and add my new variable
: ${varnishd_flags="-P ${pidfile} -a ${varnishd_listen} -f $ 
{varnishd_config} -T ${varnishd_telnet} -s ${varnishd_storage} -t $ 
{varnishd_ttl}"}

B. /etc/rc.conf

Create a variable called varnishd_ttl and set it to 3600.
: ${varnishd_ttl="3600"}

Edit varnishd_flags and add my new variable

varnishd_enable="YES"
varnishd_listen="mb-prv.kcilink.com:80"
varnishd_storage="file,/var/tmp,512M"
varnishd_config="/usr/local/etc/varnish/morebiz.vcl"
varnishd_ttl="3600"
varnishd_flags="-P ${pidfile} -a ${varnishd_listen} -f $ 
{varnishd_config} -T ${varnishd_telnet} -s ${varnishd_storage} -t $ 
{varnishd_ttl}"

c. /usr/local/etc/varnish/default.vcl

*if (obj.ttl < 3600s) {
set obj.ttl = 3600s;
}

*not exact just scratch code.

Now my question, is there a more direct way to change the default_ttl  
either through configuration files or .vcl file?  If these are pretty  
much the only three ways that is fine, I just wanted to make sure I  
wasn't skipping over any options.  Thank you in advance for your help.

Steve


More information about the varnish-dist mailing list