title: Drupal 7 & Varnish 4 - I always get X-Drupal-Cache: MISS but X-Cache: HIT
body: <p>I have run into the same issue as this person: <a href="https://groups.drupal.org/node/325428" rel="nofollow">X-Drupal-Cache for Drupal 7 website always hits MISS</a>, and can not find a way out. </p>
  
  <p>I am running Drupal 7 - <strong>Pressflow</strong></p>
  
  <p>and </p>
  
  <p>Varnish 4.0</p>
  
  <p>When I curl I get this result:</p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong><em>isvarnishworking.com</em></strong> tells me: <em>"You deserve a gold star, here you go: gold star badge"</em>....</p>
  
  <p>While the "Varnish Indicator Chrome Extension" suggested in the linked Drupal org thread, tells me Varnish missed, on every single page of my website regardless if I am logged in or not.</p>
  
  <p>If I turn Drupal cache for anonymous users at admin/config/development/performance <strong>off</strong>, Varnish will not work at all. If I set different minimum cache lifetimes there, it makes no difference.</p>
  
  <p>In my settings.php I have this:</p>
  
  <pre><code>$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;
  </code></pre>
  
  <p>and this</p>
  
  <pre><code> $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';
  </code></pre>
  
  <p>while this has been commented out from the Varnish config in settings.php because if I don't, Varnish fails:</p>
  
  <pre><code>//$conf['cache'] = 1;
  //$conf['cache_lifetime'] = 01080;
  </code></pre>
  
  <p>I have turned off all modules that could interfere, such as captcha modules, and I will note that the statistics won't count node hits correctly now, so something is being cached... </p>
  
  <p>The VCL I use is grabbed straight from <a href="https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl" rel="nofollow">this github master with minimum changes</a></p>
  
  <p>How can I troubleshoot this <strong>X-Drupal-Cache: MISS</strong> issue?</p>