简体   繁体   English

清漆不缓存多个wordpress

[英]Varnish does not cache multiple wordpress

I have setup Varnish on a high end dedicated server with WHM which is running around 10-13 websites, all on WordPress. 我在带有WHM的高端专用服务器上安装了Varnish,该服务器在WordPress上运行着大约10-13个网站。 I'm seeing that hit rate is really very low and miss rate is very high in "varnishhist". 我看到“ 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. 另外,当我执行varnishtop -i txurl ,我只是看到以非常高的速度从Apache请求“ /” URL(而不是每个网站URL)。 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. 这是我当前的VCL文件,效果很好。

 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; }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM