Jamersan | Magento and BigCommerce Elite Partner Agency

Flush Varnish with Default Magento 2 Cache

Many people are willing to install and configure Varnish on their Magento 2 instance to reap the benefit of faster page load times. Unfortunately, they tend to forget a very important step: Configuring Magento to purge Varnish with the normal Magento cache flushing process. Without this configuration, you would have to manually purge Varnish after each change, or wait for the TTL cycle to complete. Luckily, linking Varnish with the Magento Cache flushing process is quite simple.

Access your server via SSH and change to the Magento 2 root directory. From there run the following command (as the Magento file owner), adjust the IP address and port number with the values you used when setting up Varnish.

php bin/magento setup:config:set --http-cache-hosts=192.168.2.100:6087
You should see a message, “You saved the new configuration”, after running this command.

That’s it! You can now purge Varnish whenever you refresh the Magento cache via the admin (System > Tools > Cache Management > Flush Magento Cache) or via the command line (php bin/magento cache:flush or shorthand php bin/magneto c:f)

Our Leadership

TJ Gamble

CEO

Shane Rodgers

Director, Operations

Alex Schreck

Director, Sales & Partnerships

Dave Christy BigCommerce & Adobe Expert

Dave Christy

Director, Delivery