<div dir="ltr">Hi All,<div><br></div><div>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:</div><div><br></div><div>
- Create different directors for sites (e.g Site1_PRD, Site2_PRD, Site1_STG, Site2_STG)</div><div><br></div><div>- In sub choose_vhost I set the req.backend based on URL:<br>       </div><div><div>         if ((req.http.host ~ "(?i)^<a href="http://prd.site1.com">prd.site1.com</a>$") |) ) {  set req.backend = Site1_PRD; }</div>
</div><div><br></div><div>- In sub vcl_fetch I inserted an IF statement to set TTLs:</div><div><div><br></div><div>       sub vcl_fetch {</div><div><span class="" style="white-space:pre">     </span>if ( req.backend == Site1_PRD ) {<span style="white-space:pre">    </span></div>
<div><span class="" style="white-space:pre">                    </span>if (req.url !~ "\.aspx" && req.url !~ "\.htmx" && req.url !~ "\.ashx") {</div><div><span class="" style="white-space:pre">                     </span>unset beresp.http.Set-Cookie; }</div>
</div><div>                        ...</div><div>       } else { ....</div><div><br></div><div>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).</div>
<div>Is there a better way to configure different TTLs per site?</div><div><br></div><div>Thanks for the help!</div><div>Carlo Alberto Scaglia</div></div>