corestack_ varnish_ vcl_ update
Change a site's custom Varnish VCL.
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,. 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, (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
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
recv, backend_response, deliver, each text, or null or "" to empty it. A hook left out stays as it is.
Fields
Up to 49,152 characters.
Up to 49,152 characters.
Up to 49,152 characters.
Why, shown in the history. Up to 200 characters.
The row, a Magento 2 site or one of its environments. At least 1.
The version from corestack_varnish_vcl_get; a newer save makes it stale. At least 0.
Example 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
| Reason | What to do |
|---|---|
stale | Someone saved since version was read; details.version is the current one. Read the VCL again with corestack_varnish_vcl_get. |
vcl_invalid | The policy refused the VCL; nothing was saved. details.diagnostics lists each problem with its hook, line, column and code. |
vcl_compile_failed | The VCL does not compile; nothing was saved. details.diagnostics. |
vcl_locked | Corefinity manages the VCL on this environment. |
busy | A save is already applying; try again when it ends. |
varnish_not_offered | The row is not a Magento 2 site. |
managed_elsewhere | Another 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_arguments | The 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_mismatch | The object does not exist or the token may not see it. Check the id. |
scope_required | The token lacks a scope this call needs. Open the link in the answer to add it, then call again. |
pin_refused | The 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_limited | Too many calls. Wait for the number of seconds the answer names. |
temporarily_unavailable | The Control Panel could not answer just now. Nothing was started; try again shortly. |
internal_error | Something went wrong on our side. Quote the trace id to support. |