---
title: "corestack_varnish_set"
url: https://docs.corefinity.com/mcp/tools/corestack_varnish_set
type: tool
last_updated: 2026-11-13
feature: varnish
related:
  - https://docs.corefinity.com/guides/sites/software-and-services/varnish.md
---
# corestack_varnish_set

**Switch a site's Varnish on or off.** Switch Varnish on or off for a Magento 2 row (off: Magento's built-in cache). On keeps the last version unless version is given. About a minute. Scope: write. Long-running: answers with a task.

- Scope: `write`
- Runs as a task: yes

## When to use it

Switch Varnish on or off for a Magento 2 row. It is on by default; switching it off makes Magento serve pages from its built-in full-page cache, and the row stays off (the platform never switches it on again by itself) until it is switched on here or in the Corefinity Control Panel.

- **On:** saved → picked up by the platform → Varnish started → Magento pointed at Varnish → cache check → healthy. If the cache check finds the store cannot be cached (for example every page sets a cookie), the row is put back on Magento's built-in cache and the task says why.
- **Off:** Magento switched to its built-in cache → Varnish cleared → saved → picked up. Magento moves first, so nothing is cached twice; if Magento cannot be switched, nothing else changes.

Without `version`, switching on keeps the version the row had last, else the default (7.7). Read `corestack_varnish_get` first: `options[]` with `allowed: true` lists the versions you may name.

The change takes about a minute and answers a task on its `varnish_set` operation (follow it with `corestack_site_operation_get`). With `apply: window` it waits for the row's next maintenance window and answers at once `{operation: null, queued: true, window_date, item_id, window}`; track it with `corestack_pending_changes_list`. Two outcomes complete without failing: `pending_code` (the site has no code yet; Magento is configured at the first deployment) and `magento_config_failed` (Varnish runs but Magento stays on its built-in cache; repair with `corestack_function_run` and `magento_varnish_config`).

## Inputs

- `site_id` (integer, ≥ 1, required): the row, a Magento 2 site or one of its environments.
- `enabled` (boolean, required): true switches Varnish on, false switches it off.
- `version` (string, at most 8 characters): only when switching on, one of `options[].version` with `allowed: true`, such as `8.0`.
- `apply` (string, `now` or `window`; `tonight` is kept as an alias of `window`): now (the default), or in the row's next maintenance window.

### Input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "apply": {
      "default": "now",
      "description": "now, or tonight. window: the row's next maintenance window (tonight is kept as its alias).",
      "enum": [
        "now",
        "window",
        "tonight"
      ],
      "type": "string"
    },
    "enabled": {
      "type": "boolean"
    },
    "site_id": {
      "minimum": 1,
      "type": "integer"
    },
    "version": {
      "description": "Switching on: an allowed version, e.g. 8.0.",
      "maxLength": 8,
      "type": "string"
    }
  },
  "required": [
    "site_id",
    "enabled"
  ],
  "type": "object"
}
```

## Refusals

- `unchanged`: Varnish is already in that state.
- `varnish_not_offered`: the row is not Magento 2, or not on a platform version Varnish runs on yet (it is after this site's platform update).
- `varnish_too_small`: the memory share Varnish would take is below the 512 MiB floor (for example RabbitMQ on at the medium or cs4 size). Recovery: a larger package, or RabbitMQ off.
- `memory_split`: Corefinity staff have divided this environment's memory between its services by hand, Redis's included, and the switch would undo that; nothing was changed. The person asks support to make the change.
- `version_unsupported`: the version is not allowed for this Magento; the message names the offered versions and why.
- `change_in_progress` or `busy`: another change on the row is unfinished; try again when it ends.
- `change_pending`: a change is already waiting for the maintenance window.
- `feature_off` (on `apply`): waiting for the maintenance window is not available yet; send `apply: now`.
- `managed_elsewhere` (message: "This site is managed by another control panel"): 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.
- `image_not_offered` (409): the Varnish version this change needs is not one Corefinity offers right now (withdrawn, or not published yet). Nothing was changed; send it again once Corefinity offers that version.
- The refusals every tool can answer: `invalid_arguments`, `tenant_mismatch`, `scope_required`, `pin_refused`, `rate_limited`, `temporarily_unavailable`, `internal_error` (corestack://guides/how-this-server-works).

## Example

```json
{
  "name": "corestack_varnish_set",
  "arguments": {
    "site_id": 4211,
    "enabled": true,
    "version": "8.0",
    "apply": "window"
  }
}
```

## Prompt

```text
Using the Corefinity MCP server, call corestack_varnish_set with site_id 4211, enabled true, version 8.0, apply window. (Switch a site's Varnish on or off.) Tell me what it returned.
```

## The same task elsewhere

- Guide: [Varnish](https://docs.corefinity.com/guides/sites/software-and-services/varnish.md)
