I'm setting up Varnish with Magento 2. I want to know if I can use the default configuration of Varnish (/etc/default/varnish) with Magento 2 or not?

1 Answer 1


To configure Varnish with Magento 2, the process can be summarized in four steps which are explained as follows:

  1. Install Varnish. You can check out this official MAGENTO2 WITH VARNISH WIKI and set up your server accordingly. Make sure that the Varnish version is at least 3.0.5 or any version of 4.x.
  2. Login to the Magento 2 Admin Panel and navigate to STORES > Configuration > ADVANCED > System > Full Page Cache > Caching Application list > Varnish Caching and create a Varnish Configuration File (VCL) for the particular version.
  3. Replace your existing Varnish VCL File with the one generated from the Magento Admin Panel. Restart Varnish and your Web Server.

  4. Visit your store and test everything. See if there is nothing in your <your Magento install dir>/var/page_cache directory, it means you have successfully configured Varnish with Magento 2!

Note: You can also test it by accessing your Magento 2 Homepage to see if you are getting HTTP response headers that indicate Varnish is working.

For further, you can also check out this official Magento 2 DevDocs about installing and configuring Varnish with Magento 2.

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.