change ttl based on request url
Ryan Morgan
rmorgan at greenmtd.com
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 “http://internal.my.com/any/thing <http://internal.my.com/any/thing>” and the 15s ttl should be set. I’ve tried just (req.url ~ “internal.my.com <http://internal.my.com/>”) as well because I read that it should match if any part of the request url. Help is appreciated! Thanks!
-Ryan
# Cache for a longer time if the internal.my.com 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: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20151102/f27f224e/attachment.html>
More information about the varnish-misc
mailing list