Magento 2 Full Page Cache Application: Varnish vs Built-in cache

Magento 2 (M2) comes with Full Page Cache (FPC) functionality. That feature greatly improves page load speed and overall makes frontend pages faster. There are two options for M2 FPC – Built-in cache and Varnish cache. Which one to choose? Which one is better for performance? In this article we are going to find out.

What does Magento Team Recommend?

Magento team recommends to use Varnish cache for production mode.

It doesn’t backup its recommendation with an actual performance benchmark though. Let’s compare running speed with Varnish vs Built-in cache.

Benchmark Setup

We will use an average 2G VPS on which we will install Debian 8. On the server we will also install Magento 2 and Varnish 4. Installation instructions for Varnish might vary from OS to OS. For Debian it is a simple package installation procedure.

For load testing we will use siege. Siege is a HTTP stress testing and benchmarking utility. You can download and compile it yourself or use precompiled binary for your operating system. We will use the Debian siege package.

We will use file mode with siege. We will create a file site.txt with 5 URLs:


Then we will run siege command:

siege -c5 -d2 -t1M -f site.txt

The command means the benchmark test will run 1 minute with 5 concurrent users. A delay between requests will be 2 seconds. Those 5 users will request 5 URLs that are in site.txt file.

Built-in Cache Results

Magento 2 with built-in cache configuration saves full page cache content on disk in var/page_cache folder.

I run siege command I showed you earlier 5 times. Here are the results:

The average server response time or time to first byte (TTFB) is 2.34 seconds.

Varnish Cache Results

Magento 2 and Varnish setup looks like this:

A browser will send a request to Varnish. Varnish will query Magento if it doesn’t find content in cache. Varnish also gets dynamic blocks ( like cart items ) directly from Magento.

Common mistake when people setup Magento 2 and Varnish is that they didn’t put Varnish in front of Magento. In other words they didn’t make Varnish listen on port 80 and accept incoming requests.

Instead they simply set Varnish as Caching Application in Magento backend and hope for the best. Then they get poor time to first byte (TTFB) results and wonder why.

Alright back to the test. I run siege command 5 times to prevent any mistakes. Results you will see in the table below:

The average server response time (or time to first byte TTFB) is 1.47 seconds.

Varnish vs Built-in

Now let’s plot the Varnish speed results vs Built-in ones.

We see that Varnish outperforms built-in cache by almost 40%.


Varnish is definitely a way to go about Magento 2 full page cache in production mode. It is a lot faster than the default built-in option.

Make sure you setup Varnish right. Make it listen on port 80 and put it in front of Magento 2. If you are using SSL there are ways to configure Varnish to work with HTTPS but it is out of scope of this article.

About the author

Konstantin Gerasimov is a Magento Certified Developer. He specializes in backend development, speed optimization and custom extensions.

1 reply

Trackbacks & Pingbacks

  1. […] If you are still hesitating which cache works better – Varnish or Built-in, just have a look at some speed test results  […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.