gpt4 book ai didi

wordpress - Varnish 不缓存wordpress网站。尝试了博客中存在的一些解决方案。没什么对我有用

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

我能够配置 Varnish ,但我猜它不是缓存。在响应头中,我看到这些属性:

Url : corp.zip.pr

Age →0
Via →1.1 varnish-v4
X-Varnish →98319

我的 default.vcl 文件如下:
# Marker to tell the VCL compiler that this VCL has been adapted to the 
# new 4.0 format.
vcl 4.0;

# Default backend definition. Set this to point to your content server.
backend default {
.host = "127.0.0.1";
.port = "8080";
}

sub vcl_recv {
# Happens before we check if we have this in cache already.
#
# Typically you clean up the request here, removing cookies you don't need,
# rewriting the request, etc.

if (req.method == "PURGE") {

if (req.http.X-Purge-Method == "regex") {

ban("req.url ~ " + req.url + " && req.http.host ~ " + req.http.host);

return (synth(200, "Banned."));

} else {

return (purge);

}
}


if (req.url ~ "wp-admin|wp-login") {
return (pass);

}

if (!(req.url ~ "wp-(login|admin)")) {
unset req.http.cookie;
}


set req.http.cookie = regsuball(req.http.cookie, "wp-settings-d+=[^;]+(; )?", "");

set req.http.cookie = regsuball(req.http.cookie, "wp-settings-time-d+=[^;]+(; )?", "");

set req.http.cookie = regsuball(req.http.cookie, "wordpress_test_cookie=[^;]+(; )?", "");

if (req.http.cookie == "") {

unset req.http.cookie;
}
}

sub vcl_backend_response {
# Happens after we have read the response headers from the backend.
#
# Here you clean the response headers, removing silly Set-Cookie headers
# and other mistakes your backend does.


if (beresp.ttl == 120s) {

set beresp.ttl = 600s;

}
}

sub vcl_deliver {
# Happens when we have all the pieces we need, and are about to send the
# response to the client.
#
# You can do accounting or modifying the final object here.
}

此外,varnishlog 不起作用。当我在终端中输入 varnishlog 时,我看到以下消息。

Cannot open /opt/bitnami/varnish/var/varnish/_.vsm: No such file or directory



我检查了文件位置。 _.vsm 不在此处。我检查了 varnishd 进程使用的 vsm 位置。不一样
/var/lib/varnish/ip-172-31-10-1/

最佳答案

您没有return (hash);vcl_recv函数中,将其添加到函数主体的末尾,重新启动 Varnish 并检查其是否有效。

我觉得您的vcl很奇怪,例如尝试https://www.htpcguides.com/configure-wordpress-varnish-4-cache-with-apache-or-nginx/

关于wordpress - Varnish 不缓存wordpress网站。尝试了博客中存在的一些解决方案。没什么对我有用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40817939/

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