# Purge the WordPress cache with Claude Code

> Purging the WordPress cache with Claude Code means asking it, in the terminal you deploy from, to clear the xSpeed cache on the site you just changed and warm it again through xSpeed Hub.

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

The usual moment is right after a deploy. You pushed a theme change or a plugin update from the same terminal, and the live site still serves the old CSS because the cached pages point at it. Instead of opening wp-admin, you tell Claude Code which site and what changed. It calls list_sites to match the name, picks a purge type that fits the change, and runs purge_cache through the xspeedhub server you added with claude mcp add.

What comes back is the plugin's own report: which stores were cleared, how many entries, and whether a connected Cloudflare zone accepted the purge. A purge of type all covers the page cache, the object cache and, when they are connected, the Cloudflare edge and CDN, so Claude Code can tell you in one line whether anything refused. For a CSS-only change it can purge assets instead, which leaves the stored HTML alone.

Claude Code shows each tool call before it runs it unless a permission rule allows that tool, or you run it in auto mode (a classifier reviews actions instead of you) or bypassPermissions mode (no prompts), so a purge appears as mcp__xspeedhub__purge_cache with its arguments, and you approve it or not. For a purge across every site, the Hub also tells Claude Code to say "this will touch all N sites" and wait for your go-ahead before it sends the single site: "all" call.

## Set up Claude Code 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 Claude Code

Run this once. --scope user makes the server available in every project; leave it off and it applies to the current project only, which is Claude Code's default.

```bash
claude mcp add --transport http --scope user xspeedhub https://app.xspeedcache.com/xspeed/mcp
```

### 3. Sign in with /mcp

Start Claude Code, run /mcp, pick xspeedhub and finish the sign-in in your browser. You approve access on an xSpeed Hub page; there is no token to paste, and Claude Code keeps the credentials it receives and refreshes them.

```
/mcp
```

Full setup: https://xspeedcache.com/agent/claude-code/

### 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. Claude Code asks before it runs an MCP tool unless a permission rule already allows it, or you work in auto mode, where a classifier reviews actions instead of you, or in bypassPermissions mode, which skips prompts. A rule such as mcp__xspeedhub__get_cache_status allows one tool, and mcp__xspeedhub__get_* allows every read whose name starts with get_. Keep purge_cache, update_settings, toggle_cache and the other write tools on the prompt, because the Hub itself runs a write as soon as your connection allows it.

## Prompts

- I just deployed the new header to shop. Use xSpeed Hub to purge only the assets cache there and tell me what was cleared.
- With xSpeed Hub, purge every site in my workspace, then list any site where the purge failed and why.
- Use xSpeed Hub to purge the blog site fully, start the preloader, and check the hit ratio again in ten minutes.

## Example session

```
You: Pushed the new stylesheet to shop. Use xSpeed Hub to clear whatever is stale.
  → list_sites [read-only]: 6 sites; shop is shop.example.com
Agent: Only CSS changed, so an assets purge is enough and the cached HTML can stay. Purge assets on shop?
You: Yes.
  → purge_cache(site: shop, type: assets) [changes site]: 48 minified CSS and JS files cleared
Agent: Done, the assets cache on shop is empty and rebuilds on the next request. If a page still loads the old styles, its cached HTML points at the old files; say so and I will purge pages too.
```

## 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 Claude Code

If you added xspeedhub without --scope user, it only exists in the project where you ran claude mcp add, so in another repository Claude Code will say it has no xSpeed tools. Run the add command again with --scope user, or add it to that project, and sign in again with /mcp, or run claude mcp login xspeedhub from the shell, if Claude Code asks. And if you have allowed mcp__xspeedhub__* in your permissions, purges no longer prompt; scope the allow rule to the get_ tools if you want to keep seeing writes. Auto mode and bypassPermissions mode skip the prompt as well.

## 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 Claude Code purge the cache right after a deploy?

Yes. With xSpeed Hub added as an MCP server, ask it in the same session to purge the site you deployed. It calls purge_cache with the type that fits the change and reports what was cleared.

### Does Claude Code ask before it purges?

Claude Code prompts for each MCP tool call unless a permission rule allows that tool, or you are in auto mode (a classifier reviews actions instead of you) or bypassPermissions mode (no prompts). The Hub itself runs the purge as soon as your connection allows writes, so the Claude Code prompt is the check unless you allowed purge_cache or use one of those modes.

### 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](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/) · [OpenCode](https://xspeedcache.com/agent/opencode/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 Claude Code

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