How to Configure Varnish with Magento

Mobeen Sarwar
mobeensarwar
Published in
3 min readJan 31, 2023
Varnish Mechanics

Magento allows us to configure varnish with its sites. Without cache, Magento is too slow to use on production. Varnish cache is used to accelerate Magento web applications, and it is also known as HTTP reverse proxy.

Configuring varnish with multiple Magento sites has some different steps than configuring it with a single site.

Assumption: you already know how to configure it with a single website.

  1. Click Stores > Settings > Configuration > Advanced > System > Full Page Cache.

2. From the Caching Application list, click Varnish Caching.

3. Expand Varnish Configuration and enter the following information:

Magento Varnish Configuration

4. Save the Config and export VCL according to your installed Varnish version. You can check your varnish version by varnishd -V command

5. Now, back up your current default.vcl in /etc/varnish/ path

6. Copy your exported varnish.vcl to /etc/varnish/ directory as default.vcl

Remember to remove pub from health_check url, if magento root path is pub.

.probe = {
.url = "/health_check.php"; #not this "/pub/health_check.php"
}

7. Now restart your varnish and nginx server.

Restart varnish and nginx

8. Refresh your storefront page in your browser and verify the varnish in the Network tab. Ctrl+Shift+I.

Accessing the first time
Assessing later on

Thanks for reading the blog. If you face any issues while configuring varnish please drop a comment.

your thoughts are highly appreciated

--

--