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?
To configure Varnish with Magento 2, the process can be summarized in four steps which are explained as follows:
- 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.
- 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.
Replace your existing Varnish VCL File with the one generated from the Magento Admin Panel. Restart Varnish and your Web Server.
Visit your store and test everything. See if there is nothing in your
<your Magento install dir>/var/page_cachedirectory, 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.