Drupal 7& Varnish 4 - 我总是得到X-Drupal-Cache:MISS但是X-Cache:HIT

时间:2016-07-08 18:14:14

标签: caching drupal-7 varnish varnish-4 pressflow

我遇到了与此人相同的问题:X-Drupal-Cache for Drupal 7 website always hits MISS,无法找到出路。

我正在运行Drupal 7 - Pressflow

Varnish 4.0

当我卷曲时,我得到了这个结果:

TTP/1.1 200 OK
Date: Fri, 08 Jul 2016 17:45:08 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Set-Cookie: __cfduid=db5fd757e7485622ac16af86f292603f51467999908; expires=Sat, 08-Jul-17 17:45:08 GMT; path=/; domain=.adland.tv; HttpOnly
X-Content-Type-Options: nosniff
**X-Drupal-Cache: MISS**
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Cache-Control: public, max-age=86400
X-Content-Type-Options: nosniff
Content-Language: en
X-Generator: Drupal 7 (http://drupal.org)
Last-Modified: Fri, 08 Jul 2016 17:41:27 GMT
Vary: Accept-Encoding
X-Varnish: 196743 3
Age: 213
Via: 1.1 varnish-v4
**X-Cache: HIT**
X-Cache-Hits: 22
Server: cloudflare-nginx
CF-RAY: 2bf55922d49b23d8-IAD

isvarnishworking.com 告诉我:"你值得拥有一颗金星,在这里:金星徽章" ....

而#34;清漆指示灯Chrome扩展程序"无论我是否登录,在链接的Drupal组织线程中建议,告诉我Varnish错过了我的网站的每一页。

如果我在admin / config / development / performance 关闭的情况下为匿名用户打开Drupal缓存,则Varnish将无法运行。如果我在那里设置不同的最小缓存生存期,则没有区别。

在我的settings.php中,我有这个:

$conf['varnish_version'] = 4;
$conf['reverse_proxy'] = True;
$conf['reverse_proxy_addresses'] = array('127.0.0.1');
$conf['page_cache_invoke_hooks'] = FALSE;
$conf['page_cache_maximum_age'] = 86400;
$conf['cache_backends'][] = 'sites/all/modules/varnish/varnish.cache.inc';
$conf['cache_class_cache_page'] = 'VarnishCache';
$conf['reverse_proxy_header'] = 'HTTP_X_FORWARDED_FOR';
$conf['omit_vary_cookie'] = True;
$conf['drupal_http_request_fails'] = FALSE;

和这个

 $conf['cache_backends'][] = 'sites/all/modules/filecache/filecache.inc';
 $conf['cache_backends'][] = 'sites/all/modules/authcache/authcache.cache.inc';
 $conf['cache_backends'][] = 'sites/all/modules/authcache/modules/authcache_builtin/authcache_builtin.cache.inc';
 $conf['cache_class_cache_page'] = 'DrupalFileCache';

虽然这已经从settings.php中的Varnish配置中注释掉了,因为如果我不这样做,Varnish会失败:

//$conf['cache'] = 1;
//$conf['cache_lifetime'] = 01080;

我已经关闭了所有可能会干扰的模块,例如验证码模块,我会注意到统计数据现在不能正确计算节点命中率,因此正在缓存某些内容......

我使用的VCL直接从this github master with minimum changes

抓取

如何解决此 X-Drupal-Cache:MISS 问题?

1 个答案:

答案 0 :(得分:0)

您的后端显然正在发送Cookie:

Set-Cookie: __cfduid=db5fd757e7485622ac16af86f292603f51467999908; expires=Sat, 08-Jul-17 17:45:08 GMT; path=/; domain=.adland.tv; HttpOnly

在默认配置中,Varnish不会使用Set-Cookie标头缓存来自后端的对象。此外,如果客户端发送Cookie标头,Varnish将绕过缓存并直接转到后端。

相关问题