# 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.

Page: https://xspeedcache.com/agent/opencode/purge-cache/
Last updated: October 2026

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.

## Set up OpenCode once

### 1. Put 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.

### 2. Add 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.

File: `~/.config/opencode/opencode.json`

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

### 3. Sign 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.

```bash
opencode mcp auth xspeedhub
```

Full setup: https://xspeedcache.com/agent/opencode/

### 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.

## Prompts

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

## Example session

```
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
Agent: docs is purged and warming. No Cloudflare zone is connected, so nothing was sent to an edge.
```

## How it works

1. **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.
2. **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.
3. **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.
4. **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.
5. **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.

## Reference

| | |
| --- | --- |
| Tool | purge_cache (write) |
| Purge types | all, page, assets, object, rest |
| What all covers | Page cache, object cache, plus the Cloudflare edge and CDN when connected |
| Every site at once | site: "all" or a list of handles, one result per site |
| Fan-out pacing | Sites run one after another with a 1 second pause |
| Edge only | purge_cloudflare, a separate write tool |
| Re-warm | start_preloader after the purge |
| Read-only access | purge_cache is refused on a connection token with Read-only everywhere on, and for a Viewer sign-in |
| Confirmation | None on the Hub; your client's prompt is the gate |

## Rules

- 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.

## More prompts for this job

They work in any client connected to xSpeed Hub.

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

## Frequently asked questions

### Can OpenCode purge my WordPress cache?

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.

### How do I stop OpenCode from purging without asking?

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.

### What is the difference between the purge types?

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.

### Does purging xSpeed also clear Cloudflare?

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.

### Can I purge all of my sites with one prompt?

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.

### Will a purge slow my site down?

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.

## Purge the cache with other agents

[Claude Code](https://xspeedcache.com/agent/claude-code/purge-cache/) · [Claude](https://xspeedcache.com/agent/claude/purge-cache/) · [Claude Cowork](https://xspeedcache.com/agent/claude-cowork/purge-cache/) · [ChatGPT](https://xspeedcache.com/agent/chatgpt/purge-cache/) · [Codex](https://xspeedcache.com/agent/codex/purge-cache/) · [Cursor](https://xspeedcache.com/agent/cursor/purge-cache/) · [GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/purge-cache/) · [Windsurf](https://xspeedcache.com/agent/windsurf/purge-cache/) · [Gemini CLI](https://xspeedcache.com/agent/gemini-cli/purge-cache/) · [Antigravity](https://xspeedcache.com/agent/antigravity/purge-cache/) · [Zed](https://xspeedcache.com/agent/zed/purge-cache/) · [Kiro](https://xspeedcache.com/agent/kiro/purge-cache/) · [OpenClaw](https://xspeedcache.com/agent/openclaw/purge-cache/) · [Hermes Agent](https://xspeedcache.com/agent/hermes-agent/purge-cache/) · [Grok Build](https://xspeedcache.com/agent/grok-build/purge-cache/) · [ChatGPT dots](https://xspeedcache.com/agent/chatgpt-dots/purge-cache/) · [Grok](https://xspeedcache.com/agent/grok/purge-cache/) · [Grok Bot](https://xspeedcache.com/agent/grok-bot/purge-cache/) · [Muse](https://xspeedcache.com/agent/muse/purge-cache/) · [Manus](https://xspeedcache.com/agent/manus/purge-cache/) · [Kimi Code](https://xspeedcache.com/agent/kimi/purge-cache/) · [Paperclip](https://xspeedcache.com/agent/paperclip/purge-cache/) · [NanoClaw](https://xspeedcache.com/agent/nanoclaw/purge-cache/)

## More with OpenCode

- [Find out why WordPress pages are not cached with OpenCode](https://xspeedcache.com/agent/opencode/troubleshoot-cache/)
- [Scan a website for speed problems with OpenCode](https://xspeedcache.com/agent/opencode/speed-scan/)
- [Run and track PageSpeed tests with OpenCode](https://xspeedcache.com/agent/opencode/pagespeed-tests/)
- [Raise a WordPress site's PageSpeed score with OpenCode](https://xspeedcache.com/agent/opencode/optimize-site/)
- [Tune WordPress cache settings with OpenCode](https://xspeedcache.com/agent/opencode/cache-settings/)
- [Warm the WordPress cache with OpenCode](https://xspeedcache.com/agent/opencode/preload-cache/)
- [Set up the Redis object cache with OpenCode](https://xspeedcache.com/agent/opencode/object-cache/)
- [Manage Cloudflare caching with OpenCode](https://xspeedcache.com/agent/opencode/cloudflare/)
- [Manage every WordPress site at once with OpenCode](https://xspeedcache.com/agent/opencode/fleet/)

## Documentation

- How to enable Page Cache: https://xspeedcache.com/docs/page-cache/
- How to warm your cache ahead of visitors: https://xspeedcache.com/docs/preloader/
- Managing your fleet with xSpeed Hub: https://xspeedcache.com/docs/managing-your-fleet-with-xspeed-hub/
