Cookie如何影响varnish缓存? [英] How cookies affect Varnish caching?

查看:253
本文介绍了Cookie如何影响varnish缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Varnish缓存如何影响Omniture设置的第三方Cookie和Google Analytics(分析)设置的第一方Cookie?

How does Varnish caching affect third-party cookies set by Omniture and first-party cookies set by Google Analytics?

到目前为止,我看到了反对意见,人们说,由于跟踪统计信息是由JavaScript创建的(这是真实的),因此从请求中提取这些Cookie不会影响GA或Omniture。

So far I've seen opposing opinions, some people say that because the tracking stats are created by JavaScript (which is true), that stripping these Cookies from the request won't affect GA or Omniture.

但是这里,他们说这些软件设置各种cookie来跟踪循环访问者,因此剥离这些cookie

However here they are saying that these softwares set various cookies to track recurring visitors, and so stripping these cookies from the request would essentially count every user as a new visitor.

我不希望我的用户每次都作为新访问者计数。我不确定这些JavaScript嵌入是否有能力计算页面是否提供给第一次或定期访问者。

I don't want my users to count every time as a new visitor. I am not sure either that these JavaScript embeds have the ability to calculate if the page is being served to a first time or recurring visitor. Any links to offical GA or Omniture documentation is deeply appreciated.

推荐答案

Google Analytics(分析)通过您的域中的javascript设置Cookie。请参见 Google Analytics(分析)如何使用Cookie

Google Analytics sets cookies through javascript on your domain. See How Google Analytics uses cookies :


Google Analytics仅使用第一方
Cookie。这意味着Google Analytics(分析)为您的
网域设置的所有Cookie
只向您的域的服务器
发送数据。

Google Analytics uses only first-party cookies. This means that all cookies set by Google Analytics for your domain send data only to the servers for your domain.

对于varnish使用,这意味着您可以缓存页面响应,因为个人cookie不是通过Set-Cookie头设置,而是由javascript为每个人生成的。不过,Cookie会将请求发送到您的域名,以及当前的 default-vcl 说:

For varnish usage, this means that you can cache page responses because personal cookies are not set through Set-Cookie headers but generated by javascript equal for everybody. The cookies will however be sent with requests to your domain, and the current default-vcl says:

sub vcl_recv {

  ..

  if (req.http.Authorization || req.http.Cookie) {
    /* Not cacheable by default */
    return (pass);
  }
}

它说它不会做缓存查找if cookie被发送。所以在你的vcl_recv你应该'unset req.http.Cookie'或做一个查找,不管req.http.Cookie。

It says it won't do a cache lookup if cookies are sent. So in your vcl_recv you should either 'unset req.http.Cookie' or do a lookup regardless of req.http.Cookie .

这篇关于Cookie如何影响varnish缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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