Varnish is a complex system and there are many ways it can be thwarted by modules, custom code, and other things. If you're not sure if Varnish is working, there are some troubleshooting steps you can take.
Determining if Varnish is working
You can verify if Varnish is working by using the handy tool at Is Varnish working?. It provides you with a both check for the
X-Varnish header and a list of additional headers so that you can determine what your website is returning for requests.
If Varnish isn't working for your website, examine the following three major items:
- Ensure that Varnish is configured correctly, especially on Acquia Cloud, by configuring Varnish and Drupal settings according to Using Varnish.
- If your website's
max-ageis set incorrectly, you can experience issues with Varnish. Setting
max-ageto zero causes Varnish not to cache pages.
- Several Drupal modules set
SESSIONcookies, which can force requests to bypass the Varnish cache. The Help Center article Module incompatibilities with Acquia Cloud lists some of the modules that are known to bypass Varnish and potentially cause website performance problems due to lack of caching.
Examining Varnish headers
If Varnish appears to be working but you're still experiencing performance problems, you can examine the headers that Varnish is returning for requests. Although the Is Varnish working? tool can display a list of headers, you can also use one of the many Browser developer tools. If either method displays an X-Cache HIT, then your page is being served from Varnish cache. Also review the Age value, which returns the time (in seconds) that a webpage has been in the cache.
Browser developer tool examples
If you use Firebug, the results can appear similar to the following:
To review the values in Chrome, complete these steps:
- Right click anywhere on the webpage, and then click Inspect Element.
- Click the Network tab.
- Load the webpage that you want to test.
- Click the element that you want to inspect. You'll probably want the HTML, which should be the first file on the list.
- Click the Headers tab to display the information that you want.
You may find that Varnish appears to be working because its headers return a
HIT. If this is the case, but you're still experiencing high load for page views that you expect to have cached, review the Varnish cache HITS and Drupal cache MISS Help Center article to see if this is causing problems for your website.