0

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); }
}
deizel.
  • 193
  • 7
Spacedust
  • 568
  • 5
  • 13
  • 28

1 Answers1

2

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);
    }
ghloogh
  • 1,049
  • 5
  • 9
  • 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: http://pastebin.com/HGbYKz8a – Spacedust Feb 14 '12 at 16:15
  • Got it: http://pastebin.com/haQgdPYH – Spacedust Feb 14 '12 at 22:15