[Varnish] #1799: Backend request coalescing fail

Varnish varnish-bugs at varnish-cache.org
Fri Dec 18 22:55:12 CET 2015


#1799: Backend request coalescing fail
----------------------+--------------------
 Reporter:  martin    |       Owner:
     Type:  defect    |      Status:  new
 Priority:  normal    |   Milestone:
Component:  varnishd  |     Version:  trunk
 Severity:  normal    |  Resolution:
 Keywords:            |
----------------------+--------------------

Comment (by franveux):

 Hi,

 here is some VCL that converts back a pass to deliver if this happens. It
 works for me in production, avoiding pass requests to backend.


 {{{
 // workarround of  1799, assuming max-age is everytime more that 5
 seconds.
 sub vcl_hit {
   if (req.http.X-VCL-HITPASS1799) {
     // don't pass but deliver instead
     std.log("vcl_hit: FIX, pass convert to deliver");
     return(deliver);
   }
   // we've got a hit
   set req.http.X-VCL-HIT = true;
 }
 sub vcl_pass {
   if (req.http.X-VCL-HIT && req.restarts < 2) {
       // we've got a hit then a pass
       set req.http.X-VCL-HITPASS1799 = true;
       return(restart);
   }
 }
 sub vcl_deliver {
   if (req.http.X-VCL-HITPASS1799) {
     // fake age header to avoid the client comes back too quickly.
     set req.http.X-max-age = regsub(resp.http.cache-control,".*max-
 age=([0-9]+).*","\1");
     if (std.integer(req.http.X-max-age,5) <= std.integer(resp.http.age,0))
 {
       set resp.http.age = std.integer(req.http.X-max-age, 5) - 3;
     }
   }
 }


 }}}

 François V.

-- 
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1799#comment:4>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator



More information about the varnish-bugs mailing list