You can now set up Varnish cache for your Magento site through the Nimbus Hosting platform. Varnish is supported on our platform for our Oxygen package and higher and for sites running Magento 2.4 and newer.
Before getting started with Varnish you will need to install Magento 2.4 through the Nimbus Hosting platform following our guide which can be found below:
- Once you have Magento 2.4 installed, you'll firstly need to configure Magento to use Varnish as the full page cache. To do this log into your Magento admin area and go to Stores > Settings > Configuration > Advanced > System > Full Page Cache
- Then select Varnish Caching from the caching application list.
- Next, navigate to the sites configuration page and toggle on the Varnish option.
- If all goes smoothly then the sites will start loading through Varnish. If you find it’s not worked and you see a message such as “503 backend fetch failed” then simply un-toggle the Varnish button in the platform and it will revert back to normal.
- You can confirm that requests are going though Varnish by logging onto the server via SSH and running the "varnishlog" command.
Using a custom VCL file
When you enable Varnish from within the hosting app, we provide a default VCL file that's ready optimised for working on our servers. However you may wish to use a custom VCL file instead of the one we provide.
To export your sites custom VCL file navigate to the Magento 2 admin dashboard and export the sites Varnish config file. This can be found in:.
Stores> Configuration> Advanced> System> Full Page Cache> Varnish Caching> Export VCL for Varnish 6
Once you have the file, you will then need to upload this to the server and place it in the following location:
Then restart Varnish to active the new configuration.
For further reading and help with using Varnish on your website please see the Magento 2 developer documentation below: