Stratus Guides - Using Varnish

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. Now log into your STRATUS Store Panel
  6. Go to the Varnish area from the left-hand navigation menu, click to expand and select the Info section.
  7. Click Enable to start the Varnish service. (Note: this will redeploy all services)
  8. Varnish is now enabled!

Enable Varnish with Turpentine

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

  • 127.0.0.1 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. You can view the default VCL used under Varnish->Info. 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

Varnish also clears with the STRATUS cache.varnish.clear or cache.all.clear commands via SSH.

/usr/share/stratus/cli cache.varnish.clear

/usr/share/stratus/cli cache.all.clear

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

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


Last modified January 1, 0001