Skip to content

Enabling Varnish

Varnish on Stratus

When your store is live on Mojo Stratus, you will want to use Varnish for the Magento 2 FPC.  Varnish improves page load time and concurrency to a staggering degree.

Enable Varnish for Magento 2

To enable Varnish on your store, follow these steps:

  1. Log into your Magento 2 admin panel.
  2. Connect to your store admin panel and go to Stores → Settings → Configuration → Advanced → System → Full Page Cache
  3. In the FPC section, configure it as in the screenshot below varnish
  4. Save the configuration
  5. Click Export VCL for Varnish 4
  6. You can discard the downloadable file.
  7. Now log into your Stratus Store Panel
  8. Go to the Varnish area from the left-hand navigation menu, click to expand and select the Info section.
  9. Click Enable to start the Varnish service.
  10. Varnish is now enabled!

Enable Varnish with Turpentine

If you are using Magento 1 and Turpentine, the configuration for Turpentine should use:

  • nginx for the backend host

Then

  1. Log into your Stratus Store Panel
  2. Go to the Varnish area from the left-hand navigation menu, click to expand and select the Info section.
  3. Click Enable to start the Varnish service.
  4. Varnish is now enabled!

Using a Custom VCL

You can add a custom VCL under Varnish->VCL. It will cause a redeploy of services once applied. Please note that you must use the following acl purge block for purge to work correctly.

acl purge {
    "127.0.0.1";
    "192.168.0.0/16";
    "10.0.0.0/8";
}

Purging Varnish On Stratus

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

curl -X 'PURGE' -H'X-Magento-Tags-Pattern: .*' varnish

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

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