CorefinityCorefinityDocs
Open the Control PanelControl Panel
Varnish · 10 of 19

Replace a site's custom VCL

Saves the snippets sent in hooks: a snippet left out stays as it is. Send the version from the last read. The VCL is checked against the policy, compiled, saved and loaded by Varnish, which takes about a minute; one that Varnish refuses or that breaks the shop's home page is put back automatically.

PUT/api/corestack/sites/{site}/varnish/vcl

Path parameters

siteintegerRequired

The id of a site row. A website's production site and each of its environments has its own id. Digits only. At least 1.

Body

hooksobjectRequired

The snippets to change. One left out stays as it is; "" or null empties it.

Fields
backend_responsestring or null
deliverstring or null
recvstring or null
notestring or null

Why, shown in the history. Up to 200 characters.

versionintegerRequired

The version from the last read. At least 0.

Returns

200 Nothing to follow: the VCL is what the site already has (revision and operation null), or Varnish is off, so the VCL was saved and loads when Varnish is switched on (varnish_off: true).

202 The VCL was saved and is being loaded, which takes about a minute. Follow operation: its vcl.outcome says whether Varnish loaded it. Poll the operation until it finishes.

Fields of the 200 answer
appliedboolean

False, present when Varnish is off.

messagestring
operationobject or any or nullRequired

The change to follow. Null when nothing changed.

revisionobject or any or nullRequired

The new revision. Null when nothing changed.

varnish_offboolean

True when Varnish is off: the VCL loads when it is switched on.

warningsarray of objects

What the policy warns about in the saved snippets. A warning never stops the save.

Fields of each item
codestring

The policy's rule, such as VN-POL-09; the policy explains each. Left out of a finding of the compiler, which has no rule.

columninteger or null
hookstring or null

The snippet it is about (recv, backend_response or deliver), or * for the policy's limit on the snippets together. Empty for a finding of the compiler about the VCL as a whole, whose line and column are 0.

kindstringRequired

What found it: the policy (policy for an error, advice for a warning) or the compiler (compile).

policycompileadvice
lineinteger or null
messagestringRequired
severitystringRequired
errorwarning
sourcestring

What found it, in words, such as the Varnish version the compile ran on. Left out of a finding of the policy.

Fields of the 202 answer
appliedboolean

False, present when Varnish is off.

messagestring
operationobject or any or nullRequired

The change to follow. Null when nothing changed.

revisionobject or any or nullRequired

The new revision. Null when nothing changed.

varnish_offboolean

True when Varnish is off: the VCL loads when it is switched on.

warningsarray of objects

What the policy warns about in the saved snippets. A warning never stops the save.

Fields of each item
codestring

The policy's rule, such as VN-POL-09; the policy explains each. Left out of a finding of the compiler, which has no rule.

columninteger or null
hookstring or null

The snippet it is about (recv, backend_response or deliver), or * for the policy's limit on the snippets together. Empty for a finding of the compiler about the VCL as a whole, whose line and column are 0.

kindstringRequired

What found it: the policy (policy for an error, advice for a warning) or the compiler (compile).

policycompileadvice
lineinteger or null
messagestringRequired
severitystringRequired
errorwarning
sourcestring

What found it, in words, such as the Varnish version the compile ran on. Left out of a finding of the policy.

If it is refused

StatusReasonWhat to do
401noneSend a valid token as Authorization: Bearer <token>.
403company_unavailableYour company is unavailable.
403scope_requiredUse a token with the scope named in scope.
403two_factor_requiredTurn on two-factor on your account, then send again.
404feature_offThis feature is not on for your organisation yet.
409busyAnother operation is running on the site. Wait for it to finish.
409managed_elsewhereThis site is read-only here. Change it in the control panel that manages it.
409staleWhat you read has changed since you read it. Read it again, then send the change with its new version or quote.
409varnish_not_offeredVarnish is available for Magento 2 sites only. Nothing to change here.
409varnish_offVarnish is off on the environment. Switch it on first.
422invalidFix the field named in field; errors says why.
422vcl_invalidThe VCL breaks a rule of the platform. Nothing was saved. Fix what the message names.
422vcl_lockedCorefinity manages this environment's VCL. Contact support to change it.
429rate_limitedWait for the seconds in Retry-After.
503upstream_unavailableA service the action depends on did not answer. Try again later.

Reasons are listed by name in Errors and refusals.

The same task elsewhere

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
  }'
{
  "operation": null,
  "revision": null
}
Try it

Try it is off for this endpointIt overwrites data that cannot be brought back. Copy the request and run it yourself when you are sure.

Was this helpful?
Open in ClaudeOpen in ChatGPT