gpt4 book ai didi

Wordpress Varnish Age=0 或不缓存(Cookies?)

转载 作者:行者123 更新时间:2023-12-03 17:46:35 26 4
gpt4 key购买 nike

我正在使用Wordpress 3.8.1和Varnish 3.0.5。由于VCL的噩梦,我敢肯定Varnish不会缓存。而且我也不知道Wordpress的非常标准/正确的VCL在哪里。

我的Wordpress是多站点,我将Varnish放在Wordpress VM本身的顶部。 Varnish @ 8080Apache @ 80/443

由于我对VCL一无所知,因此我只使用了一个随机VCL,发现:

backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 60s;
.first_byte_timeout = 60s;
.between_bytes_timeout = 60s;
}

sub vcl_recv {
if (req.restarts == 0) {
if (req.http.x-forwarded-for) {
set req.http.X-Forwarded-For =
req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
if (req.request == "PURGE") {
if ( client.ip != "xx.xx.xx.xx") {
error 405 "Not allowed.";
}
return (lookup);
}
if (req.request != "GET" &&
req.request != "HEAD" &&
req.request != "PUT" &&
req.request != "POST" &&
req.request != "TRACE" &&
req.request != "OPTIONS" &&
req.request != "DELETE") {
return (pipe);
}
if (req.request != "GET" && req.request != "HEAD") {
return (pass);
}
if (!(req.url ~ "wp-(login|admin)") &&
!(req.url ~ "&preview=true" ) ) {
unset req.http.cookie;
}

if (req.http.Authorization || req.http.Cookie) {
return (pass);
}
return (lookup);
}

sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
return (deliver);
}

sub vcl_miss {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
return (fetch);
}

sub vcl_fetch {
if (!(req.url ~ "wp-(login|admin)")) {
unset beresp.http.set-cookie;
set beresp.ttl = 96h;
}

if (beresp.ttl <= 0s ||
beresp.http.Set-Cookie ||
beresp.http.Vary == "*") {
set beresp.ttl = 120 s;
return (hit_for_pass);
}
return (deliver);
}

(并且我将我的IP用于'xx.xx.xx.xx')

但是无论如何,通过始终获取 age : 0,这是行不通的。我知道VCL必须处理Wordpress COOKIES和其他COOKIES,例如G.A等。

怎么做,或者在哪里可以找到Wordpress的标准/正确VCL?

最佳答案

看看以下的 Varnish 模板,wordpress相当不错。认为这是成功解决问题的最快方法。根据您现有的vcl手动修复它会花费更多时间。

https://github.com/mattiasgeniar/varnish-3.0-configuration-templates

关于Wordpress Varnish Age=0 或不缓存(Cookies?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22629423/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com