I set up varnish in my site and after the set up, checked the http header for an anonymous user. This was the response:

Status: HTTP/1.1 200 OK Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
X-Drupal-Cache: MISS
Cache-Control: max-age=0, no-cache Content-Language: en
Link: http://www.website.com/; rel="canonical",http://www.website.com/; rel="shortlink",https://plus.google.com/u/0/b/randomnumber/randomnumber/; rel="publisher"
Vary: Accept-Encoding X-Mod-Pagespeed:
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Content-Length: 15365
Date: Sat, 08 Feb 2014 20:53:08 GMT
X-Varnish: 658699528
Age: 0
Via: 1.1 varnish Connection: close

This is what isvarnishworking.com has got to say on this:

Varnish appears to be responding at that url, but the Cache-Control header's "max-age" value is less than 1, which means that Varnish will never serve content from cache at this url.

This means that the purpose of me setting up varnish is not served. Is this correct? Varnishstat shows a hit to miss ratio of 50% which is good enough to start with:

83  Client connections accepted
     230  Client requests received
      21  Cache hits
      49  Cache misses
     210  Backend conn. success
     164  Fetch with Length
       1  Fetch wanted close
      39  N struct sess_mem
       1  N struct sess
      37  N struct object
      37  N struct objectcore
      26  N struct objecthead
      90  N struct smf
      16  N large free smf
       1  N struct vbe_conn
       2  N worker threads
      12  N worker threads created
  375315  N worker threads limited
     104  N overflowed work requests
       1  N backends
      12  N expired objects
       8  N LRU moved objects
     184  Objects sent with write
      82  Total Sessions
     230  Total Requests
     160  Total pass
     209  Total fetch
   84600  Total header bytes
 1377549  Total body bytes
       8  Session Closed
     223  Session Linger
     224  Session herd
   19641  SHM records
    1662  SHM writes
       1  SHM MTX contention
     213  allocator requests
      74  outstanding allocations
  409600  bytes allocated 10439155712  bytes free
     210  Backend requests made
       1  N vcl total
       1  N vcl available
       1  N total active purges
       1  N new purges added
      70  HCB Lookups without lock
      35  HCB Lookups with lock
      35  HCB Inserts
     752  Client uptime
      44  Fetch no body (304)

Here is a screeshot of the admin/configure/development/performance page:


  • 1
    The max-age=0 is set by Drupal when serving pages from a logged in user, and same with X-Drupal-Cache being set to MISS, so unless this is being seen by anonymous users, or you are somehow trying to set up Varnish to cache logged in users' pages, this is correct behavior.
    – Jimajamma
    Commented Feb 8, 2014 at 22:36
  • This is the header I got when tried as an anonymous user and that is what troubles me. You may check that yourself. Commented Feb 9, 2014 at 4:43
  • Can you give us a screen shot of your admin/config/development/performance page and cache settings?
    – Jimajamma
    Commented Feb 9, 2014 at 5:13
  • awesomescreenshot.com/01e2bplzef Commented Feb 9, 2014 at 5:17
  • all looks correct there, too. afraid at this point its going to be a lot of debugging and looking around to make sure no other installed module is mucking around with your cache control headers.
    – Jimajamma
    Commented Feb 9, 2014 at 5:41

2 Answers 2


Your content is not from cache.

See the X-Varnish header;

X-Varnish: 658699528

If the content was served by Varnish, you'd have two numbers there. Not just one.

Have you looked at using the Varnish module? I'm not sure what version of Drupal you're using though.


Fixed it by making sure that settings.php contains the following lines and rebooting afterwords:

$conf['cache_backends'] = array('sites/all/modules/varnish/varnish.cache.inc');

$conf['cache_class_cache_page'] = 'VarnishCache';

$conf['page_cache_invoke_hooks'] = FALSE;

$conf['reverse_proxy'] = TRUE;

$conf['cache'] = 1;

$conf['reverse_proxy_header'] = 'HTTP_X_FORWARDED_FOR';

$conf['reverse_proxy_addresses'] = array('');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.