change ttl based on request url

Ryan Morgan rmorgan at
Tue Nov 3 04:22:10 CET 2015

I have multiple subdomains pointing to one varnish instance. I read in the documentation that PCRE regex should be used. I believe the regex I have below should return true when the request url is “ <>” and the 15s ttl should be set. I’ve tried just (req.url ~ “ <>”) as well because I read that it should match if any part of the request url. Help is appreciated! Thanks!


# Cache for a longer time if the URL isn't used
sub vcl_fetch {
  if (req.url ~ "^[(http:\/\/)|(https:\/\/)]*internal\.my\.com.*"){
    set beresp.ttl = 15 s;
  } else {
    set beresp.ttl = 300 s;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list