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 would like to setup Varnish to purge content in cache and get it directly from backend when CTRL+R or CTLR+F5 is pressed.

I use these rules but this only gets content from backend when CTRL+F5 is pressed. When I press F5 only I get data from cache.

acl CTRLF5 {
   "127.0.0.1";
}

sub vcl_hit {

  if (client.ip ~ CTRLF5) {
    if (req.http.pragma ~ "no-cache" || req.http.Cache-Control ~ "no-cache")
    {
      set obj.ttl = 0s;
      return(pass);
    }
    else { return(deliver); }
  }
  else { return(deliver); }
}
share|improve this question
    
Which browser do you use for testing ? Could you post the request headers sent when you F5 a page ? –  Jérôme R Feb 12 '12 at 16:56
add comment

1 Answer 1

up vote 2 down vote accepted

Can be realised with next statements:

varnish 2.1.x

    if (req.http.Cache-Control ~ "no-cache"){
    purge_url(req.url);
    }

varnish 3.x

    if (req.http.Cache-Control ~ "no-cache"){
    ban(req.url);
    }
share|improve this answer
    
Firefox 10.1 when pressing F5, but I will try your rules :) HTTP/1.1 304 Not Modified Content-Type: image/jpeg Etag: "2252232387" Last-Modified: Sun, 12 Feb 2012 18:00:59 GMT Accept-Ranges: bytes Date: Sun, 12 Feb 2012 18:11:31 GMT Connection: keep-alive X-Cache: HIT Cache-Control: private Pragma: private –  Spacedust Feb 12 '12 at 18:11
    
It still doesn't work. Pressing F5 or CTLR+R gets content from cache. CTLR+F5 gets content from disk. –  Spacedust Feb 12 '12 at 18:17
    
There is a nice config, but it do not work with Varnish 3.0: pastebin.com/HGbYKz8a –  Spacedust Feb 14 '12 at 16:15
    
Got it: pastebin.com/haQgdPYH –  Spacedust Feb 14 '12 at 22:15
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.