caching - Varnish 使用 Magento 1.8.1 社区版未获取缓存结果

标签 caching varnish magento-1.8 varnish-vcl

我是 Varnish Cache 的新手。我已经在 Cent OS 服务器上成功安装了 Varnish 4(最新版本)并且配置完美。我还在响应 header 中获得了 X-Varnish,通过 1.1 varnish - v4。我发现一切都很完美。如果我停止 Varnish ,网站就会停止,这似乎是正确的。

我的问题是,尽管 Varnish 配置正确,但我的速度不够。我想,我没有得到 Varnish 缓存结果,看起来服务器总是调用后端服务器来获取结果。通常,在没有 Varnish 的情况下,需要 3-4 秒才能得到结果。安装 Varnish 后,需要相同的时间。

响应 header

Accept-Ranges bytes Age 0 Cache-Controlno-store, no-cache, must-revalidate, post-check=0, pre-check=0 Connectionkeep-alive Content-EncodinggzipContent-Typetext/html; charset=UTF-8DateFri, 01 Aug 2014 14:08:51 GMTExpiresThu, 19 Nov 1981 08:52:00 GMTPragmano-cacheServerApache/2.2.15 (CentOS)Set-Cookiefrontend=rfdi8hd6kq136puafk93lm0ra7; expires=Fri, 01-Aug-2014 15:08:51 GMT; path=/; domain=www.usapooldirect.com; httponlyTransfer-EncodingchunkedVaryAccept-Encoding,User-Agent Via 1.1 varnish-v4 X-Powered-By PHP/5.3.3X-Varnish

请求 header

Accepttext/html, application/xhtml+xml, application/xml;q=0.9 ,/;q=0.8Accept-Encodinggzip, deflateAccept-Languageen-US,en;q=0.5Connectionkeep-aliveCookiefrontend=rfdi8hd6kq136puafk93lm0ra7; external_no_cache=1; adminhtml=pt3bt6t30m4vtqdsm1ldv716v7Hostwww.usapooldirect.com Refererhttp://www.usapooldirect.com/User-Agent Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0

谢谢,

Ankit

最佳答案

您应该在 Varnishstat 的帮助下检查 Varnish 命中率。

您还可以输入以下代码,如果它是从 Varnish 缓存或后端提供的,您可以在浏览器中检查该代码。

sub vcl_deliver {
if (obj.hits > 0) {
    set resp.http.X-Cache = "HIT ("+obj.hits+")";
} else {
    set resp.http.X-Cache = "MISS";
    #    set resp.http.X-Cache-Hash = obj.http.hash;
}
return (deliver);
}

关于caching - Varnish 使用 Magento 1.8.1 社区版未获取缓存结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25083072/

相关文章:

django - 批量存储和提供静态内容的最佳方式

http - 让 Varnish 忽略带有 Cookie header 的请求

php - 您如何扩展Themosis helpers.php函数?

启用 ssl 后,Magento 站点重定向到主页

java - Spring Cacheable vs CachePut?

javascript - ServiceWorker 离线 - HTML 中没有类名

php - Yii2 redis 缓存优于文件缓存

就局部性而言,数组与链表