Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

req.url doesn't have that information. Try using req.http.Host instead?

share|improve this answer
    
Tried that as well with: if (req.http.Host ~ "^(staging.)^") { return (pass); } Still no luck. –  Will Sep 17 '13 at 0:40
1  
@Will it should be if (req.http.Host ~ "^(staging.)") { return (pass); } . There is an extra ^ symbol in it. Please check my alternative answer to see if that helps! –  Pothi Sep 17 '13 at 1:47
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.