【问题标题】:Varnish does not cache multiple wordpressVarnish 不缓存多个 wordpress
【发布时间】:2015-06-06 04:19:38
【问题描述】:

我已经在带有 WHM 的高端专用服务器上设置了 Varnish,该服务器在 WordPress 上运行了大约 10-13 个网站。我看到“varnishhist”中的命中率非常低,而未命中率非常高。此外,当我执行varnishtop -i txurl 时,我只看到 Apache 以非常高的速率请求“/” URL(而不是每个网站 URL)。以下是摘录:

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

我相信 varnish 甚至必须缓存每个站点的主页并发送回客户端,而不是从后端请求。请问有什么建议吗?

【问题讨论】:

  • 你能发布你的 vcl conf 文件吗?

标签: php wordpress caching varnish


【解决方案1】:

好的。我设法找到了解决方案。这是我当前的 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; }
}

【讨论】:

    猜你喜欢
    • 2014-05-02
    • 1970-01-01
    • 1970-01-01
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 2016-05-11
    • 2023-03-08
    • 1970-01-01
    相关资源
    最近更新 更多