Caching 第四次击中未遂头球?
是否有人更新了Varnish 4的命中未命中标题 我找到的最后一个是版本3 寻找这些:Caching 第四次击中未遂头球?,caching,varnish,varnish-vcl,Caching,Varnish,Varnish Vcl,是否有人更新了Varnish 4的命中未命中标题 我找到的最后一个是版本3 寻找这些: set beresp.http.X-Cacheable=“否:不可缓存”;“否:获取会话”; “否:缓存控制=专用”;“是” 以及其他可能有用的调试输出,说明请求丢失的原因。是的,: 将所需标题的varnish 3版本直接翻译为varnish 4: sub vcl_backend_response { if (bereq.http.Cookie ~ "(UserID|_session)") {
set beresp.http.X-Cacheable=“否:不可缓存”;“否:获取会话”;
“否:缓存控制=专用”;“是”代码>
以及其他可能有用的调试输出,说明请求丢失的原因。是的,:
将所需标题的varnish 3版本直接翻译为varnish 4:
sub vcl_backend_response {
if (bereq.http.Cookie ~ "(UserID|_session)") {
set beresp.http.X-Cacheable = "NO:Got Session";
set beresp.uncacheable = true;
return (deliver);
} elsif (beresp.ttl <= 0s) {
# Varnish determined the object was not cacheable
set beresp.http.X-Cacheable = "NO:Not Cacheable";
} elsif (beresp.http.set-cookie) {
# You don't wish to cache content for logged in users
set beresp.http.X-Cacheable = "NO:Set-Cookie";
set beresp.uncacheable = true;
return (deliver);
} elsif (beresp.http.Cache-Control ~ "private") {
# You are respecting the Cache-Control=private header from the backend
set beresp.http.X-Cacheable = "NO:Cache-Control=private";
set beresp.uncacheable = true;
return (deliver);
} else {
# Varnish determined the object was cacheable
set beresp.http.X-Cacheable = "YES";
}
# ....
return(deliver);
}
子vcl\u后端\u响应{
if(bereq.http.Cookie~“(UserID |_session)”){
设置beresp.http.X-Cacheable=“NO:Got Session”;
设置beresp.uncacheable=true;
归还(交付);
}elsif(beresp.ttl)我更喜欢这些(根据我最初问题中的直接链接):set-beresp.http.X-Cacheable=“NO:Not-Cacheable”;“NO:Got Session”;“NO:Cache Control=private”;“YES”;
谢谢!省略返回(deliver)是否明智
?为什么?因为它是默认值,并且允许处理下面的其他子vcl\u backend\u响应。
sub vcl_backend_response {
if (bereq.http.Cookie ~ "(UserID|_session)") {
set beresp.http.X-Cacheable = "NO:Got Session";
set beresp.uncacheable = true;
return (deliver);
} elsif (beresp.ttl <= 0s) {
# Varnish determined the object was not cacheable
set beresp.http.X-Cacheable = "NO:Not Cacheable";
} elsif (beresp.http.set-cookie) {
# You don't wish to cache content for logged in users
set beresp.http.X-Cacheable = "NO:Set-Cookie";
set beresp.uncacheable = true;
return (deliver);
} elsif (beresp.http.Cache-Control ~ "private") {
# You are respecting the Cache-Control=private header from the backend
set beresp.http.X-Cacheable = "NO:Cache-Control=private";
set beresp.uncacheable = true;
return (deliver);
} else {
# Varnish determined the object was cacheable
set beresp.http.X-Cacheable = "YES";
}
# ....
return(deliver);
}