CorefinityCorefinityDocs
Open the Control PanelControl Panel
Software and services · 8 of 8

Varnish VCL

Add your own VCL snippets to a Magento 2 site's Varnish, test them and go back to an earlier revision.

On this page

Before you start

  • You can open the site in Managed Websites. Anyone who can open a site can change its VCL.
  • Varnish is on. The Varnish VCL section shows only while it is.

Add a snippet

  1. Open Varnish VCL

    Go to Managed Websites, choose the site, then Varnish VCL under Site settings.

  2. Write it, or insert one

    Choose the tab of the hook your snippet runs in, vcl_recv, vcl_backend_response or vcl_deliver, and write your VCL. The Snippets tab beside the editor has ready-made ones: choose Insert.

  3. Test

    Choose Test: it checks the snippets against the rules and compiles them on the site's Varnish version, without applying anything. If it finds errors, Show problems lists what to fix.

  4. Save and apply

    Choose Save, enter a Note if you want one in History, then choose Save and apply. Tick Purge everything once it is applied to start from an empty cache.

The revision applies live. If Varnish cannot load it or the site stops answering with it, the previous revision is put back.

Your snippets run inside the platform's VCL. The Platform VCL tab shows it; it cannot be edited.

Limits

Each hook16 KB and 200 statements.
All hooks48 KB.
RulesTest checks the snippets against the rules every save must pass, and Show problems lists what breaks one.

Go back to an earlier revision

  1. Open History

    Every save adds one revision. Choose History in the message Varnish VCL saved, which shows for 6 seconds after a save, or Show history in the message about a revision that was put back.

  2. Revert

    Choose Revert to this on the revision, then Revert. It is tested first, then saved as a new revision with the older content.

Managed by Corefinity on the section means support manages this environment's VCL. Contact support to change it.

Automate this

Varnish VCL

Saves the snippets sent in hooks: a snippet left out stays as it is.

PUT/api/corestack/sites/{site}/varnish/vcl
curl -X PUT https://manage.corefinity.com/api/corestack/sites/1042/varnish/vcl \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "hooks": {
      "backend_response": "if (bereq.url ~ \"^/size-guides/\") { set beresp.ttl = 1d; }"
    },
    "note": "Cache the size guides for a day",
    "version": 1
  }'
Was this helpful?
Open in ClaudeOpen in ChatGPT