gpt4 book ai didi

Varnish - PURGE 请求不会清除 hash_data() URL

转载 作者:行者123 更新时间:2023-12-01 05:10:28 26 4
gpt4 key购买 nike

在 vcl_hash 中,我有

backend default {
.host = "127.0.0.1";
.port = "8080";
}
acl purge {
"localhost";
}
sub vcl_hash {
if(req.http.Cookie ~ "isLogin") {
hash_data("1");
}
}
sub vcl_recv {
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
return (lookup);
}
return(lookup);
}
sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
purge;
error 404 "Not in Cache.";
}
}

我正在使用以下命令来清除 url。
curl -X PURGE http://release.com/user/details

如果为已注销的用户缓存 url,我会得到以下输出
curl -X PURGE http://release.com/user/details
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>200 Purged.</title>
</head>
<body>
<h1>Error 200 Purged.</h1>
<p>Purged.</p>
<h3>Guru Meditation:</h3>
<p>XID: 1071483546</p>
<hr>
<p>Varnish cache server</p>
</body>
</html>

如果它只为登录用户缓存,我会一直低于输出。 (即使 url 正在制作“点击”)
curl -X PURGE http://release.com/user/details
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>404 Not in Cache.</title>
</head>
<body>
<h1>Error 404 Not in Cache.</h1>
<p>Not in Cache.</p>
<h3>Guru Meditation:</h3>
<p>XID: 998719206</p>
<hr>
<p>Varnish cache server</p>
</body>
</html>

http://release.com/user/details如果用户登录与否,看起来会有所不同。 (即它是否有 isLogin cookie)。 PURGE 不适用于在 vcl_hash 中散列的 url。
似乎是 Varnish 的错误或功能。请建议,可以做什么。

最佳答案

我发现在我的情况下问题可能对你和任何使用 vcl_hash 和清除的人都是一样的。散列用于清除,因此所有用于散列的请求信息都将存在以进行清除。在您的情况下,您检查 cookie if(req.http.Cookie ~ "isLogin")所以你必须用清除请求发送这个 cookie,如:

curl -X PURGE --cookie "isLogin=1" http://release.com/user/details

如果要清除散列的所有变体,则需要调用它两次,一次使用 cookie,一次不使用。

关于 Varnish - PURGE 请求不会清除 hash_data() URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25470449/

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