Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
sub vcl_recv {
    if (req.request ~ "^/c/") {
       if ( (req.http.cookie ~ "abc=;") && (req.http.cookie ~ "xyz=;") ){
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

Your Answer


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.