This article is based on the Varnish for Beginners talk that Adam Malone presented at DrupalACT.
Varnish is a reverse proxy HTTP accelerator that is often placed in front of Drupal websites to cache content, usually for anonymous website visitors. Because Varnish is a separate service, the type of the Drupal site's web server software (such as Apache, Nginx, Comanche, or Internet Information Services (IIS)) doesn't matter - it just works.
If your website has content that a large group of visitors periodically and simultaneously visit, it doesn't make sense to size your server large enough to handle even the largest possible group of website visitors. Instead, you would make your site's content available to an application that can serve copies of content instead (Varnish) of having to re-create each content page dynamically for each website visitor..
Scalability. For each end user accessing the back end of your Drupal site, queries are made between the website and the database, active cache, spam filter, and update service. A web page is then built dynamically and delivered to the user. This system works fine for low-traffic sites, but if you re looking to support the heavy traffic a large audience brings, your server alone will struggle under the weight. Varnish works to take the load off of your server.
There are many advantages to using Varnish, including the following:
All of these together make websites behind Varnish fast! Even though the effects are felt only by anonymous users, the majority of traffic for most websites is likely anonymous. Reducing the strain from anonymous users also frees up resources for authenticated users.
Although Drupal has several potential caching strategies, it's arguably Varnish that provides the easiest one to set up when balanced against speed benefits:
Note: Acquia Cloud uses Memcached, and does not necessarily support other methods.
Memcached forms a cache backend that Drupal can interact with actively to set and get cached items where Varnish is a passive cache that Drupal does not know about.
One of the easiest ways to ensure that Varnish is working as expected is to visit the Is Varnish Working website and enter your website's URL. You will get a success or fail message along with your site's headers.
You can also manually verify Varnish operations. Use the following command at a command prompt:
curl -IXGET http://domain.com
Where domain.com
is your site's domain. This returns the headers for the document you request and generally looks like this:
HTTP/1.1 200 OK
Date: Mon, 22 Jan 2018 23:04:51 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=d6c58f722d3094e112b801cda1b28ad611516662291; expires=Tue, 22-Jan-19 23:04:51 GMT; path=/; domain=.acquia.com; HttpOnly
Cache-Control: max-age=2764800, public
X-Drupal-Dynamic-Cache: UNCACHEABLE
Link: </node>; rel="canonical"
Link: </node/1>; rel="shortlink"
Link: </node>; rel="revision"
X-UA-Compatible: IE=edge
Content-language: en
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Mon, 22 Jan 2018 14:14:53 GMT
Vary: Cookie,Accept-Encoding
X-Generator: Drupal 8 (https://www.drupal.org)
X-Drupal-Cache: HIT
X-Request-ID: v-9fda8610-ff7e-11e7-95e6-06fa32497e48
X-AH-Environment: prod
X-Varnish: 5054236 5052240
Age: 31794
Via: 1.1 varnish-v4
X-Cache: HIT
X-Cache-Hits: 2750
Server: cloudflare
CF-RAY: 3e162797e45b5dba-BNE
The important lines are X-Cache: HIT
, which says that it was not a cache MISS
, and Age: 31794
because that confirms that the page has been stored in cache for that amount of time.
In Chrome, you can also use Developer Tools to see the HIT or MISS value.
Varnish will hold cached pages in its memory until it expires. After this period, the page will be discarded from the cache. The next time this content is requested, it will be created and delivered by the backend, and a new static copy will be stored in the Varnish cache. If necessary, you can manually invalidate cached objects by either purging them from the cache or banning them from being served from the cache. Varnish Software provides training material for these cache invalidation strategies.
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Wed Oct 22 2025 08:59:29 GMT+0000 (Coordinated Universal Time)