问题
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