xSpeed Cache is officially live! Get 50% OFF during Launch Week — Lifetime starts at just $79Lifetime from $79 — 50% OFF, Launch Week! See Plans →

See Plans →
Features
xSpeed Hub Pricing Docs Blog Scan
Appearance
Get Plugin

Purge the WordPress cache with OpenCode

Purging the WordPress cache with OpenCode means asking it, from the terminal you deploy in, to clear the xSpeed cache on the site you just changed through the xSpeed Hub remote server in your OpenCode config.

list_sitesget_cache_statuspurge_cachepurge_cloudflarestart_preloader

Last updated: October 2026

Example session · OpenCode

You: Deployed to docs. Use xspeedhub to purge the cache and warm it.

list_sites read-only
→ 6 sites; docs is docs.example.com

purge_cache(site: docs, type: all) changes site
→ page cache purged (96 entries), object cache flushed, no Cloudflare zone connected

start_preloader(site: docs) changes site
→ preloader started, 96 URLs queued

OpenCode: docs is purged and warming. No Cloudflare zone is connected, so nothing was sent to an edge.

01

How OpenCode handles this

You are in an OpenCode session in your project terminal after a deploy, and a page is serving old markup. You type the site and what changed, and OpenCode calls list_sites to match the name, then purge_cache with a type that fits, then start_preloader if you asked. Each call and its result print in the session, so you can read exactly what was sent.

OpenCode sessions are plain text, so the report is easy to copy into a deploy log. It is the plugin's report: the type, the site, how many entries cleared, and for all the object cache and a Cloudflare edge when it is connected. If a connected Cloudflare zone refused the purge, the report says so on the same line, and OpenCode can tell you whether to retry or leave it. Because the session sits in the same terminal as your deploy, you can ask for the cache status straight afterwards and compare the hit ratio before and after the purge.

OpenCode has a permission config with three settings, ask, allow and deny, and most permissions default to allow. With no rule of yours in place, purge_cache runs without a prompt, because xSpeed Hub has no confirmation of its own. Add an ask rule for the xspeedhub tools, then allow the reads, since the last matching rule wins. For a purge across every site, the Hub also tells OpenCode to say that it will touch all the sites and wait for your yes, which is guidance to the model, not a lock.

02

Set up OpenCode once

Already connected? Skip to the prompts. Alternatives and troubleshooting are on the OpenCode guide.

1Put your sites in xSpeed Hub

Sign in at app.xspeedcache.com with Google or email; the Hub is free and has no site cap. Then connect each WordPress site from its own dashboard: click Connect Hub in the xSpeed Cache top bar, then Connect via xSpeed Hub. Each site needs the free xSpeed Cache plugin.

2Add xSpeed Hub to your config

Put this block in your global config, or in opencode.json at a project root to scope it to that project. OpenCode reads both JSON and JSONC. No other field is needed: when the Hub answers 401, OpenCode starts the OAuth flow and registers itself through dynamic client registration.

~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "xspeedhub": {
      "type": "remote",
      "url": "https://app.xspeedcache.com/xspeed/mcp"
    }
  }
}

3Sign in with opencode mcp auth

Run this once. It opens a browser page on xSpeed Hub where you sign in and approve access. There is no token to paste; OpenCode stores the credentials it receives. Run opencode mcp list to see the server and its auth status, and opencode mcp debug xspeedhub if the connection fails.

Terminal
opencode mcp auth xspeedhub
1 / 3

Full OpenCode setup, sign-in options and FAQ

Before you send a prompt that changes something

Reads change nothing on your sites, though contact_support emails xSpeed support. Writes run once your connection allows them, so your client's approval prompt and a read-only connection (the token's Read-only everywhere switch, or a Viewer sign-in) are the gates that matter. OpenCode checks MCP tools against its permission rules under the prefixed name, such as xspeedhub_purge_cache, and most permissions default to allow. With no rule of yours in place, a Hub write tool runs without a prompt. Add rules to change that: "xspeedhub_*": "ask" first, then "xspeedhub_get_*": "allow" and "xspeedhub_list_*": "allow", because the last matching rule wins. A deny rule holds even under opencode --auto, which approves everything that is not denied. The Hub itself has no confirmation step, so these rules and read-only access are the gates. For read-only access, send the connection token with Read-only everywhere on, or sign in as a Viewer member.

03

What do I ask?

Three prompts written for OpenCode. More for this job are below.

Prompt for OpenCode
Use xspeedhub to purge docs fully, start the preloader, and paste the report so I can copy it into the deploy log.
Prompt for OpenCode
I only changed CSS on shop. Use xspeedhub to purge the assets cache there.
Prompt for OpenCode
Use xspeedhub: purge every site in my workspace, then list any that failed and why.
04

What happens, step by step

A purge throws away stored copies so the next visitor gets a fresh page. Through xSpeed Hub an agent can purge everything, only pages, only CSS and JavaScript assets, the object cache or the REST cache, on one site or across every site in a workspace. A full purge also clears the Cloudflare edge when the site has Cloudflare connected.

01

Find the site

The agent calls list_sites when you have more than one site, then matches the name you used to a site handle. If the name could mean two sites, the Hub tells it to ask you rather than guess.

02

Pick the purge type

purge_cache takes a type: all, page, assets, object or rest. all clears the page cache, the object cache and, when they are connected, the Cloudflare edge and CDN. After a theme or CSS change, assets is enough; after a content edit, page; after a deploy, all.

03

Purge

The call runs straight away on that site once your connection allows writes. For every site at once the agent passes site: "all", and the Hub runs the sites one after another with a one-second pause.

04

Clear only the edge if that is all you need

purge_cloudflare empties the Cloudflare edge cache on its own, without touching the copies on your server. A page or assets purge does not reach Cloudflare; a purge of type all does when Cloudflare is connected.

05

Warm it again

start_preloader rebuilds the cache in the background so the first visitors after the purge are not the ones paying for it.

05

Reference

Toolpurge_cache (write)
Purge typesall, page, assets, object, rest
What all coversPage cache, object cache, plus the Cloudflare edge and CDN when connected
Every site at oncesite: "all" or a list of handles, one result per site
Fan-out pacingSites run one after another with a 1 second pause
Edge onlypurge_cloudflare, a separate write tool
Re-warmstart_preloader after the purge
Read-only accesspurge_cache is refused on a connection token with Read-only everywhere on, and for a Viewer sign-in
ConfirmationNone on the Hub; your client's prompt is the gate
06

Rules worth keeping

  • Name the site. With several sites, an unclear name should make the agent ask, and the Hub tells it to.
  • A purge of every site is one call with site: "all". The Hub tells the agent to confirm it with you once before it runs.
  • Purge the narrowest type that fixes the problem, then warm the cache, so visitors do not all hit uncached pages at once.
  • A fan-out result is reported per site. Treat some sites failing as a partial result, not a failure of the whole call.

Good to know with OpenCode

OpenCode starts from permissive defaults, so until you add an ask or deny rule for the xspeedhub tools, purge_cache runs on the model's say-so. Put the catch-all ask rule first and the allow rules for the reads after it. A deny rule holds even under opencode --auto, so in a project that should never purge from the terminal, deny xspeedhub_purge_cache and add a connection token with Read-only everywhere on for extra safety. Sign in before your first session in a new environment as well, because a server that is configured but not signed in reports an error instead of purging.

07

More prompts for this job

They work in any client connected to xSpeed Hub.

Prompt
Use xSpeed Hub to purge the page cache on blog.
Prompt
I just changed the theme CSS on shop. Use xSpeed Hub to purge only the assets cache there.
Prompt
With xSpeed Hub, purge every site in my workspace and tell me which ones failed.
Prompt
Use xSpeed Hub to purge shop, then purge its Cloudflare edge cache too.
Prompt
With xSpeed Hub, purge the docs site and start the preloader so it is warm again.
Prompt
Using xSpeed Hub, what purge type should I use after updating a plugin that changes the checkout page?
08

Frequently asked questions

Yes. With xSpeed Hub added as a remote MCP server in your OpenCode config, ask it in a session to purge the site you deployed. It calls purge_cache with the type that fits and prints what was cleared.

OpenCode allows most tools by default, so add an ask rule for the xspeedhub tools, or a deny rule for purge_cache in a project where it should never run. xSpeed Hub has no confirmation of its own, so an allow rule, or no rule at all, lets the purge run at once. A connection token with Read-only everywhere on, or a Viewer sign-in, refuses every purge as well.

all clears every cache xSpeed manages for the site, including a connected Cloudflare zone or CDN. page clears the stored HTML pages, assets clears minified and combined CSS and JavaScript, object clears the Redis or Memcached object cache, and rest clears cached REST API responses.

A purge of type all does, when the site has Cloudflare connected in xSpeed: it clears the page cache, the object cache and the Cloudflare edge, and reports each one. A page, assets or rest purge stays on your server. purge_cloudflare clears only the edge.

Yes. The agent passes site: "all" to purge_cache and the Hub purges every site in the workspace one after another, returning a result per site. The Hub tells the agent to confirm a write across every site with you once before it runs it.

The next request to each purged page builds it fresh, which is slower than a cached hit. Starting the preloader right after the purge rebuilds the cache in the background so visitors mostly land on warm pages.

09

Keep going

Purge the cache with other agents

More with OpenCode

Documentation

From the blog

Purge the cache, from OpenCode.

xSpeed Hub is free and has no site cap. Connect your sites once and ask from the agent you already use.