无法通过 Varnish 4 缓存登录 [英] Unable to login through Varnish 4 cache

查看:17
本文介绍了无法通过 Varnish 4 缓存登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助.我怎样才能在新版本中做到这一点?因为 vcl_fetch 已经过时了,它现在在 Varnish 4 中不被接受.

I need some help. How can I do this in new version? since vcl_fetch is old and it is not accepeed now in Varnish 4.

sub vcl_fetch{
if (beresp.http.set-cookie ~ "sessionid" || beresp.http.set-cookie ~ "csrftoken") {
           return (pass);
         } else {
               return (deliver);
         }
}

推荐答案

Vcl_fetch 已移至 vcl_backend_response.

Vcl_fetch has been moved to vcl_backend_response.

也就是说从 vcl_backend_response 返回传递不是一个好主意.你应该把你的return (pass)改写成

That said it's not a good idea to return pass from vcl_backend_response. You should rewrite your return (pass) to

set beresp.uncacheable = true;
set beresp.ttl = 120s;
return (deliver);

您的整个 vcl_backend_response 应如下所示

Your whole vcl_backend_response should look like the following

sub vcl_fetch{
if (beresp.http.set-cookie ~ "sessionid" || beresp.http.set-cookie ~ "csrftoken") {
  set beresp.uncacheable = true;
  set beresp.ttl = 120s;
  return (deliver);
     } else {
           set beresp.ttl = 10s;
           set beresp.grace = 1h;
     }

}

这篇关于无法通过 Varnish 4 缓存登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆