仅清除单个会话中的caching资产

目前,我设法configurationvarnish来caching来自1个用户的项目,但是当第二个用户进入varnish时从Apache获取另一个资源。

如何将静态资产caching在可从多个用户访问的magento(css,js,image pdf等)中?

在vcl_recv上,我configuration了:

if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") { unset req.http.Https; unset req.http.Cookie; return (lookup); } 

在vcl_fetch上:

 if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) { if (beresp.http.Content-Type ~ "text/html" || beresp.http.Content-Type ~ "text/xml") { # do something } else { unset beresp.http.expires; unset beresp.http.set-cookie; set beresp.ttl = 300h; } 

我怀疑这有什么要做的vcl_hash存储caching与某种客户端的指纹。

有没有办法来操纵它只散列某些资产types的方式?

编辑1:完整configuration: http : //pastebin.com/mzSVpEqN

正如评论中指出的那样,注释掉vcl_hash函数(假设你不需要它),希望你能看到改进。

HTH!

我find了解决这个问题的方法。

Varnish为每个特定的User-Agent存储不同的caching页面。 我发现以下技术来规范用户代理( https://www.varnish-cache.org/trac/wiki/VCLExampleNormalizeUserAgent

我把所有的东西都放到了一个篮子里,看到了大量的点击量。

在vcl_recv上:

 if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") { set req.http.user-agent = "Mozilla"; unset req.http.Https; unset req.http.cookie; return (lookup); } 

Varnish将从后端兑现Vary头文件。 除非后端发送Vary:User-Agent,否则没有理由规范User-Agent客户机头。