Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top