gpt4 book ai didi

varnish - 缓存条件不适用于Wordpress cookie

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

所以我试图根据找到的 cookie 设置我的缓存条件。我正在使用以下代码,但由于 cookie 页面缓存了 24 小时,因此该功能无法正常工作。任何人都可以看看并让我知道我下面的代码中有什么问题吗?

if (req.http.Cookie ~"(wp-postpass|wordpress_logged_in|comment_author_)") {
set cacheable = false;#versions less than 3
beresp.ttl>0 is cacheable so 0 will not be cached
set beresp.ttl = 0s;
} else {
set beresp.cacheable = true;
set beresp.ttl=300s;#cache for 24hrs
}

最佳答案

所以你的代码缺少 set beresp 标志使用下面的代码,然后测试它会完美地工作。

if (req.http.Cookie ~"(wp-postpass|wordpress_logged_in|comment_author_)") {
set beresp.cacheable = false;#versions less than 3
beresp.ttl>0 is cacheable so 0 will not be cached
set beresp.ttl = 0s;
} else {
set beresp.cacheable = true;
set beresp.ttl=300s;#cache for 24hrs
}

关于varnish - 缓存条件不适用于Wordpress cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37755291/

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