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 need some advice here for default.vcl. Here's the rules:

  1. Only cache pages with urls that contains '/c/', the rest will pass
  2. Set the cache expiry to 3 hours
  3. Only cache and serve from cache if cookie 'abc' and cookie 'xyz' is empty

Thank you!

share|improve this question
add comment

1 Answer

sub vcl_recv {
    if (req.request ~ "^/c/") {
       if ( (req.http.cookie ~ "abc=;") && (req.http.cookie ~ "xyz=;") ){
        lookup;
       }
    }
    pass;
}
sub vcl_fetch {
    if (req.request ~ "^/c/") {
        set obj.ttl = 10800s;
    }
}

however, empty and not set are two different things. Set up a test, you can use varnishlog on another session to see precisely what varnish is doing (it is quite detailed) and then adjust the rules to do what you need.

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.