Set Different TTL based on website

Carlo Alberto Scaglia carloalberto.scaglia at gmail.com
Wed Jan 29 12:22:14 CET 2014


Hi All,

i'm trying to set different TTLs for different sites which are running on
the same backend of my Varnish servers, this is how I tried to implement it:

- Create different directors for sites (e.g Site1_PRD, Site2_PRD,
Site1_STG, Site2_STG)

- In sub choose_vhost I set the req.backend based on URL:

         if ((req.http.host ~ "(?i)^prd.site1.com$") |) ) {  set
req.backend = Site1_PRD; }

- In sub vcl_fetch I inserted an IF statement to set TTLs:

       sub vcl_fetch {
if ( req.backend == Site1_PRD ) {
if (req.url !~ "\.aspx" && req.url !~ "\.htmx" && req.url !~ "\.ashx") {
unset beresp.http.Set-Cookie; }
                        ...
       } else { ....

The problem is that it seems that this causes a lot of random 503 errors,
while backend is working properly and it is also very difficult to manage
because for every new site I need to nest another IF in the root else
statement (and I think this cause an increased computational load).
Is there a better way to configure different TTLs per site?

Thanks for the help!
Carlo Alberto Scaglia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140129/cd673f72/attachment.html>


More information about the varnish-misc mailing list