How to Install Varnish Cache on Windows
Caching is not just a process of storing data in a temporary storage unit but also one of the pillars of web performance optimization. It’s a powerful technique to make your website load faster. The website can’t be called optimized without using a caching system.
In Magento 2, cleaning and flushing cache is essential after modifying configuration files, to apply the required changes. It collects configuration from all modules, merges it, and saves the merged result to the cache. This cache also contains store-specific settings stored in the file system and database.
By default, you can configure Magento 2 ‘Caching Application’ from Stores > Configuration > Advanced > System > Full Page Cache . You can see ‘Varnish Cache’ option with the recommended label.
You have to install varnish cache on windows to use its functionalities and configure it as this post shows you how to do it.
Let me first introduce “varnish” to you and how it’s different from the Magento default cache.
Varnish cache is a web application accelerator which stores files or fragments of files in memory to reduce the response time and network bandwidth consumption on future equivalent requests.
The varnish is a much quicker option and will give you the flexibility to cache most of your content, including HTML documents!
“Built-in “Full Page Cache” is enough for better performance”, and it’s the common misbelief while using Magento 2!
Individually, I recommend you to use built-in cache in development mode however when your store is in production mode, I strongly recommend using Varnish Cache for the optimal performance.
Steps to Install Varnish Cache on Windows
- Install Full Cygwin environment with varnish package
- 32 bits installer: https://cygwin.com/setup-x86.exe
- 64 bits installer: https://cygwin.com/setup-x86_64.exe
- Here I’m using 64 bits installer
- Double click on setup-x86_64.exe and start the installation.
- Check the setup version and click on Next button.
- Choose the installation type. Here I want to install it from the internet.
- Select the root directory where you want to install it.
- Select local package directory from “Browse” button and click on the “Next” button.
- Select the site(s) from the list or add your site to the list by entering it in User URL textbox, and click “Add”.
- After progressing, the next dialogue box will display several packages and allow you to select packages to install.
- Search for ‘varnish’ in the Search filter of Select Packages popup, and then select the appropriate package and click “Next”.
- It will display the list of installation packages to review and confirm. Click on “Next” once reviewed.
- Click on “Next” after it completes 100% progress.
- After it finishes the installation, double click its icon that resides on the desktop.
You can see the command prompt by double-clicking this icon.
To check if varnish is installed or not, run the following command in the terminal.
varnishd -V
It returns the version of Installed varnish.
Finally, the installation is done. You can configure varnish cache from Magento 2 store’s backend.
That’s it!
Quite lengthy but installed!
If you have any doubts, just mention them in the Comments section below.
I would be happy to help.
Feel free to share the solution with Magento 2 community via social media.
Thank You.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
4 Comments
Hi Team,
Thanks for the detail explanation.
I am getting same problem that ‘Satish Choudhary’ is getting (after running command varnishd -V getting varnishd: command not found)…as checked, for me…varnished file is available at /usr/sbin.
Thanks!
Hello Wakar,
At first check whether the environment variable is set with the path of installed varnish folder or not.
https://d.pr/7oih3h
Thank You
Hi ..I installed varnish on windows but when i run the command varnishd -V ..i get the error that command not found.
Hello,
Please check if the varnished file is there in /usr/sbin path or not.
This error occurs due to the wrong path of the varnished file.
Thank You.