1. Home
  2. Magento 2 Guides
  3. Purge the Varnish FPC

Purge the Varnish FPC

If you have Varnish enabled, the check the running processes, you will see the daemon running with settings like this:

The 6082 port listed above it the port set in Mojo Host Manager, and used for your Varnish configuration, while to purge Varnish, you need to use the 8072 port. A maximum of 4 daemons can run on a single server on the following ports corresponding to the listen ports and management ports.

Listen Port Management Port
8072 6082
8073 6083
8074 6084
8075 6085

Knowing the above, you can use –http-cache-hosts to specify a comma-separated list of Varnish hosts and listen ports with the bin/magento setup:config:set command to configure Magento 2 to purge the Varnish cache.  The parameter format must be <hostname or ip>:<listen port>.

For example:
php70 bin/magento setup:config:set --http-cache-hosts=127.0.0.1:8073

Be sure to match the port in your command to the instance of Varnish enabled for the website on the Advanced tab in MHM.   You should see some output like the following:

The Varnish cache is then purged when you refresh the Magento cache in the Magento Admin or using SSH.

To refresh the cache from the admin panel, go to System->Tools->Cache Management, then click Flush Magento Cache.

To refresh the cache using SSH, enter the following command as the Magento 2 filesystem owner from the document root:

Purge with curl

You can also try this via CLI from localhost.

Static files not refreshing

Magento 2 currently has a bug in its VCL: where static files will not refresh despite the purge listed above. See https://github.com/magento/magento2/issues/8113

As a workaround, you can run this command via the shell on your MageMojo server –

Further reading

For more understanding about Magento 2 and Varnish, please read the official dev docs at http://devdocs.magento.com/guides/v2.0/config-guide/varnish/use-varnish-cache.html

Purging Varnish On Stratus

Curl still works if you are using SSH, the difference is the Varnish hostname is varnish

Magento 2 users should set their http-cache-host accordingly:

php bin/magento setup:config:set –http-cache-hosts=varnish

Updated on June 1, 2018

Was this article helpful?

Related Articles