清漆缓存第一次命中

清漆缓存第一次命中

本文介绍了清漆缓存第一次命中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在专用服务器上运行 varnish.当我加载一个页面时,它会通过 Apache 传送,在第二次和后续点击时,它会通过 Varnish Cache 传送(即我可以在 X-Varnish 标头中看到两个时间戳).

I'm running varnish on a dedicated server. When i load a page, it is delivered via Apache and on the second and subsequent hits it is then delivered via Varnish Cache (i.e. I can see two timestamps in X-Varnish headers).

但是,当我从其他计算机打开同一页面时,它再次从后端 (apache) 首次交付,并在进一步重新加载时来自 Varnish.

But when i open up the same page from some other computer, it's again delivered from the backend (apache) for the first time and on further reloads it comes from Varnish.

如果一个页面已经在 Varnish Cache 中,即使是第一次在新计算机上,它不是应该通过 Varnish 传送吗?我试过简单的 hello world php 文件,没有任何具有相同效果的数据库调用.可能是我的 vcl 文件有问题,还是 Varnish 只能以这种方式工作?

If a page is already in Varnish Cache, isn't it supposed to be delivered via Varnish even on a new computer for the first time? I've tried simple hello world php files without any database calls with the same effect. Might it be something wrong with my vcl file or Varnish works this way only?

推荐答案

Jon 是对的.我有类似的问题.您还需要在测试前清理您的 cookie 和缓存.检查第一次访问响应头是否尝试设置cookie.如果是这样,您可以在 vcl_fetch 下执行unset beresp.http.Set-Cookie.

Jon is right. I had similar problem. You also need to clean up your cookie and cache before test. Check if the first visit response header, it tries to set cookie. If so, you can do "unset beresp.http.Set-Cookie under vcl_fetch.

这篇关于清漆缓存第一次命中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 13:00