[Varnish] #191: Varnish won't cache if apache keepalive is set to on

Varnish varnish-bugs at projects.linpro.no
Thu Dec 20 07:25:21 CET 2007


#191: Varnish won't cache if apache keepalive is set to on
-------------------------+--------------------------------------------------
 Reporter:  michael.lee  |       Owner:  phk      
     Type:  defect       |      Status:  new      
 Priority:  high         |   Milestone:           
Component:  varnishd     |     Version:  1.1.1    
 Severity:  normal       |    Keywords:  keepalive
-------------------------+--------------------------------------------------
 We found when apache keep alive is on, some contents never got cache.

 Here is the vcl file we used. Please note that we enabled varnish to cache
 contents even when cookies are present. I don't know if it makes any
 difference or not. But I'm just giving you enough information to help you
 address the root cause.

 {{{
 backend default {

         set backend.host = "localhost";

         set backend.port = "81";

 }

 sub vcl_recv {

     if (req.request != "GET" && req.request != "HEAD") {
         pipe;
     }

     if (req.http.Expect) {
         pipe;
     }

     if (req.http.Authenticate) {
         pass;
     }

     if (req.http.Cache-Control ~ "no-cache") {

         pass;

     }

     lookup;

 }

 sub vcl_pipe {

     pipe;

 }

 sub vcl_pass {

     pass;

 }

 sub vcl_hash {

     set req.hash += req.url;

     set req.hash += req.http.host;

     //set req.hash += req.http.cookie;

     hash;

 }

 sub vcl_hit {

     if (!obj.cacheable) {

         pass;

     }

     deliver;

 }

 sub vcl_miss {

     fetch;

 }

 sub vcl_fetch {

     if (!obj.valid) {

         error;

     }

     if (!obj.cacheable) {

         pass;

     }

     if(obj.http.Set-Cookie){

        pass;

     }

     if(obj.http.Pragma ~ "no-cache" ||
        obj.http.Cache-Control ~ "no-cache" ||
        obj.http.Cache-Control ~ "private"){

        pass;

     }

     insert;

 }

 sub vcl_deliver {

     deliver;

 }

 sub vcl_timeout {

     discard;

 }

 sub vcl_discard {

     discard;

 }


 }}}

 We found when apache keepalive is set to "on", dynamic contents can't be
 cached.

 We have set the Cache-control, Pragram and Expires headers correctly for
 dynamic contents. It works perfect when apache keepalive set to "off".


 I don't know if this ticket relates to ticket #55 or not

 Please help to investigate.

 Many thanks in advance,

 Michael

-- 
Ticket URL: <http://varnish.projects.linpro.no/ticket/191>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator


More information about the varnish-bugs mailing list