I have setup Varnish on a high end dedicated server with WHM which is running around 10-13 websites, all on WordPress. I'm seeing that hit rate is really very low and miss rate is very high in "varnishhist". Also, when I do varnishtop -i txurl
, I just see "/" URL (and not each website URL) being requested from Apache at really very higher rate. Below is an excerpt:
4.02 TxURL /
1.00 TxURL /wp-content/uploads/2014/12/034kj343.jpg
0.96 TxURL /wp-content/uploads/2014/12/dfkkj30434.jpg
0.96 TxURL /wp-content/uploads/2014/10/3403402022.jpg
I believe that varnish must even cache the home page of every single site and send back to client rather than requesting from backend. Any suggestions please?
OK. I managed to find the solution. Here is my current VCL file which works very good.
sub vcl_recv{
if (req.http.Cookie && req.http.Cookie ~ "(wordpress_|PHPSESSID)")
{ return(pass); }
if (req.url ~ "wp-admin|wp-login") {
return (pass);
}
else{
unset req.http.Cookie;
} #since we can not unset all, but leave wp-admin
}
sub vcl_backend_response {
if (bereq.url !~ "wp-admin|wp-login") {
unset beresp.http.Set-Cookie;
}
#beware that you are ignoreing all the headers now:
unset beresp.http.Cache-Control;
# cache everything for 60 minutes
if(beresp.ttl <= 0s) { set beresp.ttl = 3600s; }
}