Caching 在uri+;领域
我已经安装了varnish来服务我的缓存内容 在我的网站上,我有wordpress,并添加了规则,如果传入和传出的cookie不属于wp admin或wp login,则删除它们Caching 在uri+;领域,caching,cookies,varnish,vcl,Caching,Cookies,Varnish,Vcl,我已经安装了varnish来服务我的缓存内容 在我的网站上,我有wordpress,并添加了规则,如果传入和传出的cookie不属于wp admin或wp login,则删除它们 sub vcl_recv { if (!(req.url ~ "wp-(login|admin)")) { unset req.http.cookie; } } 及 现在我在不同的域/子域上添加了一些需要启用cookie的其他站点;我尝试添加规则,但没有
sub vcl_recv {
if (!(req.url ~ "wp-(login|admin)")) {
unset req.http.cookie;
}
}
及
现在我在不同的域/子域上添加了一些需要启用cookie的其他站点;我尝试添加规则,但没有成功,我解决的唯一方法是不缓存某些域/子域
我在想类似的东西(用于recv和fetch),但它不起作用,而且它也符合wordpress规则:
sub vcl_fetch {
if (!(req.url ~ "wp-(login|admin)") || !(req.http.host ~ "ingredienti\.popeating\.it")) {
unset beresp.http.set-cookie;
}
}
如果存在大多数WP站点或非WP站点,正确的方法可能会有所不同 鉴于您只有一个WP站点,且WP域为
my.wordpress.tld
,您应该将规则更改为:
sub vcl_recv {
if ( req.http.host ~ "my.wordpress.tld"
&& ! (req.url ~ "wp-(login|admin)")
) {
unset req.http.cookie;
}
}
#...
sub vcl_fetch {
if ( req.http.host ~ "my.wordpress.tld"
&& ! (req.url ~ "wp-(login|admin)")
) {
unset beresp.http.set-cookie;
}
}
sub vcl_recv {
if ( ! req.http.host ~ "my.not-wordpress.tld"
&& ! (req.url ~ "wp-(login|admin)")
) {
unset req.http.cookie;
}
}
#...
sub vcl_fetch {
if ( ! req.http.host ~ "my.not-wordpress.tld"
&& ! (req.url ~ "wp-(login|admin)")
) {
unset beresp.http.set-cookie;
}
}
用类似于(req.http.host~“my1.wordpress.tld”| req.http.host~“my2.wordpress.tld”)的or表达式替换req.http.host~“my.wordpress.tld”
,可以很容易地概括2+WP站点的代码
鉴于您只有一个非WP站点,且非WP域为my.not wordpress.tld
,您应将规则更改为:
sub vcl_recv {
if ( req.http.host ~ "my.wordpress.tld"
&& ! (req.url ~ "wp-(login|admin)")
) {
unset req.http.cookie;
}
}
#...
sub vcl_fetch {
if ( req.http.host ~ "my.wordpress.tld"
&& ! (req.url ~ "wp-(login|admin)")
) {
unset beresp.http.set-cookie;
}
}
sub vcl_recv {
if ( ! req.http.host ~ "my.not-wordpress.tld"
&& ! (req.url ~ "wp-(login|admin)")
) {
unset req.http.cookie;
}
}
#...
sub vcl_fetch {
if ( ! req.http.host ~ "my.not-wordpress.tld"
&& ! (req.url ~ "wp-(login|admin)")
) {
unset beresp.http.set-cookie;
}
}
同样,用类似于(req.http.host~“my1.not wordpress.tld”| | req.http.host~“my2.not wordpress.tld”)的or表达式替换req.http.host~“my2.not wordpress.tld”
,很容易为2+非WP站点概括代码
注:
您应该了解cookie条带化的含义,以及在请求上条带化cookie与避免在响应上设置cookie之间的区别
复制粘贴时要小心,因为在vcl\u fetch
和vcl\u recv