我让Varnish几乎可以使用Wordpress和Total Cache。
但是isvarnishworking.com告诉我age为0。有趣的是,如果我再次尝试使用相同的URL,那么一切正常,并且我可以看到age不再为0
它会为我尝试的每个网址执行此操作。我也可以在浏览器中验证这一点。
有什么可以解释的是,在第一个请求时(对于所有客户端),最大年龄为0,但从第二个请求开始,最大年龄是正常的?
我可以理解,如果清空了缓存,并且仅在第一次请求时才这样做。但是这里是每个客户的第一个请求。
vcl_recv:
# Drop any cookies sent to Wordpress.
if (!(req.url ~ "wp-(login|admin)")) {
unset req.http.cookie;
}
# Anything else left?
if (!req.http.cookie) {
unset req.http.cookie;
}
vcl_fetch:
# Drop any cookies Wordpress tries to send back to the client.
if (!(req.url ~ "wp-(login|admin)")) {
unset beresp.http.set-cookie;
}
最佳答案
Varnish 标题“Age”与高速缓存控制参数“max-age”不同。这只是告诉您该对象刚刚进入缓存。 5s之后,您应该会看到“年龄:5”。
特别是从sec 14.6 of RFC 2616
The Age response-header field conveys the sender's estimate of the amount of time since the response (or its revalidation) was generated at the origin server. A cached response is "fresh" if its age does not exceed its freshness lifetime.
关于wordpress - Varnish 的第一个请求的最大年龄= 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35398900/