Nexcess Logo

How to enable Varnish for Magento 2 on Nexcess Cloud

Knowledge Base Home

Notice anything different?

We've enhanced the appearance of our portal and we're working on updating screenshots. Things might look different, but the functionality remains the same.
September 11, 2019

How Nexcess Cloud clients can enable Varnish, a web application accelerator for static images.

What you need

  • Your Client Portal login credentials. If you cannot locate them, click Forgot Password? on the login page.

  • An existing Nexcess Cloud Magento 2 account. See How to create Nexcess Cloud accounts for more information.

  • Login credentials and admin access to your Magento 2 store.

Step 1: Enable the Varnish container

  1. Log in to your Client Portal. From the home page, click Plans 

  2. From the home page, click your desired Magento cloud service. 

  3. Select Menu > Containers

  4. In the Varnish section on the Containers page, click Enable.

  5. Choose your plan, then click Enable. If you are unsure of which plan to choose, contact our sales team between 9 a.m.–5 p.m. eastern time (ET), Monday through Friday.  

  6. Allow a few moments for setup to complete, then note the hostname and port information for use in Steps 2E–2F. 

Step 2: Configure your Magento 2 store

  1. Verify your Magento 2 store is in production mode. To display the current mode from the command line, issue:
    php bin/magento deploy:mode:show
    See the Magento 2 documentation for information about changing modes.

  2. Log in to your Magento 2 admin panel. To do this from your Client Portal, select Menu > Environment, then click App Admin.

  3. Select Stores < Configuration.

  4. Scroll down and select Advanced > System.

  5. Select Full Page Cache. In Caching Application, clear the Use system value check box, then select Varnish Cache (Recommended).

  6. Under Varnish Configuration, in the Backend host field, enter the hostname in Step 2F you were provided from Step 1F. In the Backend port field, enter the number for "Main Port" that is shown in the Portal (see Step 1F above).

  7. Click Save Config.

  8. To verify the proper flushing of your cache, issue the following, but replace ENDPOINT and PORT with the indicated values.

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

Using the information from Step 2F as an example, the command would be:

php bin/magento setup:config:set

Step 3: Verify full-page caching is enabled

  1. From the command line, enter:
    php bin/magento cache:status
  2. If you see a 0 next to full_page, as below:

    Then, enter:
    php bin/magento cache:enable full_page

Purge the cache in the portal

If you need to purge the Varnish page cache for your site you can do so in the performance menu tab of the portal.

Then click on the Purge Cache button which will clear the NGNIX micro-cache and the Varnish page cache.

Purging the cache in Magento

  1. To purge the cache using command line, enter:
    php bin/magento cache:clean
    php bin/magento cache:flush
  2. To purge the cache from admin, click SYSTEM > Tools > Cache Management, then click Flush Magento Cache at the top of the page.

DISCLAIMER: If you are configuring varnish for a secondary domain, you will need to contact support as the last step to get the domain added to the varnish map.

For 24-hour assistance any day of the year, contact our support team by email or through your Client Portal.

Jason Dobry
We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.