CorefinityCorefinityDocs
Open the Control PanelControl Panel
Varnish · 9 of 12

corestack_varnish_vcl_update

Change a site's custom Varnish VCL.

Scope writeRuns as a taskNo secrets returned
On this page

When to use it

Save custom Varnish VCL for a Magento 2 row and apply it live, with the version corestack_varnish_vcl_get answered. Read corestack_varnish_policy_get and check the VCL with corestack_varnish_vcl_validate first.

The save runs the policy and the compile check, records a new revision, commits it and Varnish loads it without dropping a request. The answer is a task on its varnish_vcl_change operation (follow it with corestack_site_operation_get): policy → compiled → loaded → checked. If Varnish refuses the VCL, or the site answers errors after it is loaded, the previous revision is put back automatically and the task ends with the reason; Varnish keeps serving the previous revision throughout. The revision's status in corestack_varnish_vcl_history_list moves from saving to applied, rejected or rolled_back.

The finished task's result carries vcl, what Varnish did with the revision, and so does corestack_site_operation_get for this operation at any time (the same object, also while it runs): {revision, status, outcome, applied, applied_at, reason, warnings}. outcome is applied (Varnish confirmed it), pending_verify (committed but not confirmed yet; it is checked again shortly, so read corestack_varnish_vcl_history_list later), refused (Varnish refused it; the previous revision is serving), verify_failed (the check after loading failed and the previous revision is being put back; read corestack_varnish_vcl_history_list until it says rolled_back) or rolled_back (the previous revision is confirmed back). reason says why. Only applied: true means the new VCL is live. A failed task carries the same vcl in its details.

While Varnish is switched off the VCL is checked and saved, and applies when Varnish is switched on: the answer is at once {operation: {id, status_tool}, revision, applied: false, varnish_off: true} (the operation only commits the files). Saving the content the row already has answers {operation: null, revision: null}. 20 saves and reverts a minute for each row, whoever sends them.

Ask for it

Prompt
Using the Corefinity MCP server, call corestack_varnish_vcl_update with site_id 4211, version 5, hooks {"backend_response":"if (bereq.url ~ \"^/size-guides/\") {\n    set beresp.ttl = 1d;\n}\n"}, note Cache the size guides for a day. (Change a site's custom Varnish VCL.) Tell me what it returned.

Inputs

hooksobjectRequired

recv, backend_response, deliver, each text, or null or "" to empty it. A hook left out stays as it is.

Fields
backend_responsestring or null

Up to 49,152 characters.

deliverstring or null

Up to 49,152 characters.

recvstring or null

Up to 49,152 characters.

notestring

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

site_idintegerRequired

The row, a Magento 2 site or one of its environments. At least 1.

versionintegerRequired

The version from corestack_varnish_vcl_get; a newer save makes it stale. At least 0.

Example call

tools/call
{
  "name": "corestack_varnish_vcl_update",
  "arguments": {
    "site_id": 4211,
    "version": 5,
    "hooks": {
      "backend_response": "if (bereq.url ~ \"^/size-guides/\") {\n    set beresp.ttl = 1d;\n}\n"
    },
    "note": "Cache the size guides for a day"
  }
}

If it is refused

ReasonWhat to do
staleSomeone saved since version was read; details.version is the current one. Read the VCL again with corestack_varnish_vcl_get.
vcl_invalidThe policy refused the VCL; nothing was saved. details.diagnostics lists each problem with its hook, line, column and code.
vcl_compile_failedThe VCL does not compile; nothing was saved. details.diagnostics.
vcl_lockedCorefinity manages the VCL on this environment.
busyA save is already applying; try again when it ends.
varnish_not_offeredThe row is not a Magento 2 site.
managed_elsewhereAnother control panel manages this site, so use that control panel for it. This is refused before anything else about the site, as in the Control Panel and the API. Nothing was done.
invalid_argumentsThe arguments do not match the tool's input schema, or the Control Panel refused a field. Fix the fields named in the answer and call again.
tenant_mismatchThe object does not exist or the token may not see it. Check the id.
scope_requiredThe token lacks a scope this call needs. Open the link in the answer to add it, then call again.
pin_refusedThe grant is limited to chosen clusters, sites or environments, and this call is outside them. Open the link in the answer to widen it.
rate_limitedToo many calls. Wait for the number of seconds the answer names.
temporarily_unavailableThe Control Panel could not answer just now. Nothing was started; try again shortly.
internal_errorSomething went wrong on our side. Quote the trace id to support.

The same task elsewhere

Was this helpful?
Open in ClaudeOpen in ChatGPT