Dear users,<br>this is my Varnish config for use it at "100%" (to cache all) for about "5" min.<br>Have you any <span lang="en"><span>comments or tips for me?<br>
Are there other way or </span></span><span lang="en"><span>optimizations?<br>Why Varnish </span></span><span lang="en"> <span>does not keep</span> <span>everything in</span> <span>cache by default?<br>
<br>Thanks<br>Regards<br><br></span></span><br><span lang="en"><span><span lang="en"><span></span></span>##############################################<br>backend [...]<br><br></span></span><span lang="en"><span></span></span>##############################################<br>
sub vcl_recv {<br><br>     if (req.restarts == 0) {<br>
        if (req.http.x-forwarded-for) {<br>            set req.http.X-Forwarded-For =<br>                req.http.X-Forwarded-For + ", " + client.ip;<br>        } else {<br>            set req.http.X-Forwarded-For = client.ip;<br>

        }<br>     }<br><br>     # Direct connections from 1.2.3.4 IP<br>     if (client.ip == "1.2.3.4"{<br>         return (pipe);<br>     }<br><br>     # CACHE ALL!<br>     if (req.request == "GET" || req.request == "HEAD") {<br>

        return (lookup);<br>     }<br><br>     if (req.request != "GET" &&<br>         req.request != "HEAD" &&<br>         req.request != "PUT" &&<br>         req.request != "POST" &&<br>

         req.request != "TRACE" &&<br>         req.request != "OPTIONS" &&<br>         req.request != "DELETE") {<br>         /* Non-RFC2616 or CONNECT which is weird. */<br>
         return (pipe);<br>
     }<br>     if (req.request != "GET" && req.request != "HEAD") {<br>         /* We only deal with GET and HEAD by default */<br>         return (pass);<br>     }<br>     if (req.http.Authorization || req.http.Cookie) {<br>

         /* Not cacheable by default */<br>         return (pass);<br>     }<br>     return (lookup);<br> }<br><br>##############################################<br>sub vcl_pipe {<br>     set bereq.http.connection = "close";<br>

     return (pipe);<br>}<br><br>##############################################<br>sub vcl_hit {<br>    return (deliver);<br>}<br><br>##############################################<br>sub vcl_miss {<br>    return (fetch);<br>

}<br><br>##############################################<br>sub vcl_fetch {<br>    if (beresp.ttl <= 0s ||<br>        beresp.http.Set-Cookie ||<br>        beresp.http.Vary == "*") {<br>                /*<br>                 * Mark as "Hit-For-Pass" for the next 5 minutes<br>

                 */<br>                set beresp.ttl = 300s;<br>                return (hit_for_pass);<br>    }<br>    return (deliver);<br>}<br><br>##############################################<br>sub vcl_deliver {<br>

   # Check if working<br>   if (obj.hits > 0) {<br>     set resp.http.X-Cache = "HIT";<br>  } else {<br>     set resp.http.X-Cache = "MISS";<br>  }<br>   return (deliver);<br>}<br><br><br>