Unable to login through Varnish 4 cache

老子叫甜甜 提交于 2019-12-25 08:32:11

问题


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);
         }
}

回答1:


Vcl_fetch has been moved to vcl_backend_response.

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);

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;
     }

}



来源:https://stackoverflow.com/questions/40144405/unable-to-login-through-varnish-4-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!