Varnish
Switch Varnish on or off for a Magento 2 site, change its version and purge its cache.
On this page
Before you start
- You can open the site in Managed Websites. Anyone who can open a site can change its Varnish.
- The site runs Magento 2 on the Medium (8 GB) package or larger.
- Varnish takes its memory from the full-page-cache share of Redis and the unused RabbitMQ share. PHP memory and the price do not change.
Switch Varnish on or off
Open Varnish configuration
Go to Managed Websites, choose the site, then Software & services under Site settings. Choose Configure… beside Full-page cache.
Use the switch
The switch at the bottom of Varnish configuration reads On or Off. Turn it on or off.
Confirm
To switch on, choose the Version, then Switch on. To switch off, choose Switch off.
The change takes about a minute to apply, plus up to 3 minutes before it starts.
| What happens | |
|---|---|
| Switch on | Magento is pointed at Varnish, which keeps whole pages in memory so repeat visits are answered without running PHP. Admin, checkout, customer pages and signed-in API calls are never cached. |
| Switch off | Magento moves to its built-in full-page cache in Redis first. Your VCL and the version you chose are kept. |
Change the version
While Varnish is on, choose Change… beside Full-page cache. The dialog marks the versions your Magento release supports, and your VCL is checked against the new one before the change starts.
The cache starts empty after a version change.
Purge the cache
Deployments purge everything for you, and Magento purges by tag when you save a product, category or page. To purge by hand:
Open the purge dialog
Choose Purge… in Varnish configuration, or Purge Varnish… in the site header's … menu.
Choose what to purge
Choose Everything, By tag, By address or By pattern, fill it in, then choose the purge button.
| Choice | Limit |
|---|---|
| By tag | Up to 50 Magento cache tags. |
| By address | Up to 30 addresses. |
| By pattern | Up to 5 patterns, matched from the start of the path, query included. |
A site has 10 purges an hour. Purges that deployments and Magento make do not count.
Automate this
Switches Varnish on or off for a Magento 2 site.
curl -X PUT https://manage.corefinity.com/api/corestack/sites/1042/varnish \
-H "Authorization: Bearer $COREFINITY_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"enabled": false
}'Your assistant calls corestack_varnish_set.
{
"name": "corestack_varnish_set",
"arguments": {
"site_id": 4211,
"enabled": true,
"version": "8.0",
"apply": "window"
}
}