I'm trying to configure varnish not to cache any domain that begins with "staging" using the pass method like so:
if( req.url ~ "^(staging.)" )
I suspect I'm using VCL selectors wrong but after looking around on the n
If you'd like Varnish "not to cache" and "not to look up in the cache", then the following should work...
# not to look up in the cache
sub vcl_recv {
if( req.http.host ~ "^staging" ) {
return( pass );
}
# other directives
}
# not to cache
sub vcl_fetch {
if( req.http.host ~ "^staging" ) {
return( hit_for_pass );
}
}
For more info, checkout a similar solution from the official book on Varnish.
req.url
doesn't have that information. Try using req.http.Host
instead?
if (req.http.Host ~ "^(staging.)^") { return (pass); }
Still no luck.
if (req.http.Host ~ "^(staging.)") { return (pass); }
. There is an extra ^
symbol in it. Please check my alternative answer to see if that helps!
Sep 17, 2013 at 1:47