# Warm the WordPress cache with Codex

> Warming the WordPress cache with Codex means asking it, in the terminal where it already works on your code, to start the xSpeed preloader on a site through xSpeed Hub and to check its progress.

Page: https://xspeedcache.com/agent/codex/preload-cache/
Last updated: October 2026

Codex is usually open on a repository when the cache goes cold. You merged a change, the release went out, and you ask it to warm the site that runs from that repository. It matches the name against list_sites, calls start_preloader on that handle, and the plugin begins crawling the sitemap in the background. You never leave the session to open wp-admin or run a crawl by hand.

To watch it, ask for progress. Codex calls get_preloader_status, a read that reports whether a run is active and how far through the URL list it has got. If the crawl overlaps with something heavy, tell Codex to stop it and it calls stop_preloader. Pages already warmed stay cached. For one site only, you can also let Codex use the preloader command of WP-CLI when it has a shell on that server, though the Hub route needs no server access at all.

Codex has a sandbox and an approval policy, and those govern shell commands. MCP tools have their own settings: each server takes default_tools_approval_mode (auto, prompt, writes or approve), and each tool can override it. By default Codex asks only about MCP calls that advertise side effects or a destructive annotation, and xSpeed Hub's tools declare neither, so that default does not cover start_preloader. Set the server to prompt, then give get_preloader_status an approve override so the read runs quietly. The Hub runs a start as soon as your connection allows writes, so approval_policy never, the yolo flag or an auto-approving reviewer leave nothing in front of the crawl.

## Set up Codex 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 and sign in

Add the server with its URL, then log in. The login opens an xSpeed Hub page in your browser; approve access there. There is no token to paste, and Codex keeps the credentials it receives. Start Codex and type /mcp to see the server.

```bash
codex mcp add xspeedhub --url https://app.xspeedcache.com/xspeed/mcp
codex mcp login xspeedhub
```

### 3. Keep the Hub's tools on a prompt

Open ~/.codex/config.toml. Set the server to prompt for every tool, then let one read tool run without a question. The tool timeout defaults to 60 seconds, and a PageSpeed test can take up to about two minutes, so raise it.

File: `~/.codex/config.toml`

```toml
[mcp_servers.xspeedhub]
url = "https://app.xspeedcache.com/xspeed/mcp"
default_tools_approval_mode = "prompt"
tool_timeout_sec = 150

[mcp_servers.xspeedhub.tools.get_cache_status]
approval_mode = "approve"
```

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

### 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. Codex has two layers for shell work: the sandbox mode limits what commands can touch, and the approval policy sets when Codex stops to ask. MCP tools have their own settings. Each server takes default_tools_approval_mode (auto, prompt, writes or approve) and each tool can override it with approval_mode. Codex also asks about MCP calls that advertise side effects or a destructive annotation, but xSpeed Hub's tool definitions do not declare either, so do not rely on that default for the Hub; set the server to prompt. approval_policy never, --yolo and an auto_review reviewer take the human out of the loop. xSpeed Hub has no confirmation step of its own, so an approved or auto-approved write runs as soon as your connection allows writes.

## Prompts

- The release just shipped. Use xSpeed Hub to warm the shop site and show me the preloader progress once.
- With xSpeed Hub, check get_preloader_status on blog and stop the preloader if it has been running for a while.
- Use xSpeed Hub to warm only the two sites I changed today, shop and docs, and report each result.

## Example session

```
You: Release is out. Use xSpeed Hub to warm the docs site.
  → get_preloader_status(site: docs) [read-only]: Idle, no run in progress
  → start_preloader(site: docs) [changes site]: Refused: the preloader module is disabled on this site
Agent: The preloader module is off on docs, so the site will not crawl. I can switch it on with update_settings on the preloader module. Shall I?
You: Yes, turn it on.
  → update_settings(site: docs, module: preloader, values: { enabled: true }) [changes site]: Preloader module enabled
  → start_preloader(site: docs) [changes site]: Queued 120 URLs from the sitemap; pages are fetched in the background
Agent: Started. The crawl works through the queue a few pages at a time; ask me for the status when you want it.
```

## How it works

1. **Check the cache and the preloader**: get_cache_status tells the agent whether page caching is on, because there is nothing to fill when it is off. get_preloader_status shows whether a crawl is already running, so the agent does not start a second one.
2. **Make sure the preloader is switched on**: The preloader module is off on a fresh install, and the site refuses start_preloader until it is on. The agent can read the module with get_settings and, if you agree, switch it on with update_settings on the preloader module. The Hub tells the agent to briefly confirm intent before an update_settings call, but that is guidance to the agent, not a lock.
3. **Start the crawl**: start_preloader makes the site read its sitemap, follow any nested sitemap indexes, drop URLs that your cache exclusion rules skip, and queue the rest. The call returns once the queue is built; the pages are then fetched in the background, a few per run. For every site at once the agent passes site: "all", and the Hub starts the sites one after another with a one-second pause.
4. **Watch the progress**: get_preloader_status reports whether a crawl is running, how many URLs it has processed out of the total, the last URL it visited and the most recent errors. It works on one site at a time, so for several sites the agent calls it once per site.
5. **Read what failed**: A page that answers 403 or 406 usually means a server firewall is blocking the warmer by its user-agent, not that the page is broken. The status message names the user-agent to allow. A crawl that queues no URLs is reported as an error with the reason, not as a success.
6. **Stop it if the server struggles**: stop_preloader ends a running crawl. It is safe mid-run: pages already warmed stay cached. The agent can stop one site or every site in the workspace.

## Reference

| | |
| --- | --- |
| Start and stop | start_preloader and stop_preloader (write) |
| Progress | get_preloader_status (read): running or not, processed out of total, last URL, recent errors |
| What gets crawled | The sitemap (the WordPress one at /wp-sitemap.xml unless you set another), nested indexes followed, excluded URLs skipped |
| Needs | The preloader module switched on (it is off by default) and page caching on |
| Pages per run | 5 by default, 1 to 50, set in the preloader module |
| Schedule setting | manual, hourly, daily or weekly, set in the preloader module |
| Every site at once | start_preloader and stop_preloader accept site: "all"; get_preloader_status does not |
| Fan-out pacing | Sites start one after another with a 1 second pause, one result per site |
| Warmer user-agent | xSpeed-Warmer/1.0, the string a firewall rule would need to allow |
| Stopping | Safe mid-run; warmed pages stay cached |
| Read-only access | A Viewer member's sign-in, or the connection token with Read-only everywhere on: start_preloader and stop_preloader are refused; get_preloader_status works. An OAuth sign-in by anyone else gets the scopes the client asks for. |
| Confirmation | None on the Hub; your client's prompt is the gate |

## Rules

- Warm after a purge, not instead of one. The Hub tells the agent that starting the preloader after a purge saves the next visitor from paying for the rebuild.
- A crawl requests every page in the sitemap, so it adds load to the origin. Start with one site, and on a small host keep Pages per run low or stop the crawl if the site slows.
- start_preloader and stop_preloader are write tools. The Hub calls the preloader low-risk and only asks the agent to confirm when the target site is unclear or the call covers every site, so your client's approval prompt and read-only access (a Viewer sign-in, or the connection token with Read-only everywhere on) are the gates that matter.
- A fan-out only starts the crawls. Check each site with get_preloader_status afterwards, and treat some sites failing to start as a partial result, not a failure of the whole call.

## Good to know with Codex

Codex's default does not put a prompt in front of the Hub's tools, because they declare no side-effect annotation. Set the server to prompt and Codex asks before every Hub call, start_preloader and stop_preloader included. A per-tool approve override on the start runs it without a question, on any site the agent names. approval_policy never and --yolo remove prompts for everything, MCP calls included, so for any run you start that way, and for codex exec in scripts or CI where nobody can answer a prompt, use the connection token with Read-only everywhere on (or a Viewer sign-in).

## More prompts for this job

They work in any client connected to xSpeed Hub.

- Use xSpeed Hub to start the preloader on shop and tell me how many URLs it queued.
- Using xSpeed Hub, how far through its crawl is blog? Show processed against total and any errors.
- With xSpeed Hub, purge the cache on docs, then warm it again.
- Use xSpeed Hub to start the preloader on every site in my workspace and tell me which ones refused.
- Use xSpeed Hub to stop the preloader on shop. It is slowing the server down.
- The preloader on shop says it is disabled. Use xSpeed Hub to turn the module on, then start the crawl.
- Using xSpeed Hub, which of my sites has no running crawl and a low hit ratio?

## Frequently asked questions

### Should Codex use the Hub or WP-CLI to warm my cache?

Use the Hub when you want one connection for every site, with no server access. Use WP-CLI when Codex already has a shell on the server and you only care about that one site. Both reach the same plugin preloader.

### Can Codex warm every site I run in one go?

Yes, by passing site: "all" to start_preloader. The Hub runs the sites one after another and returns a result per site. It tells the agent to confirm once with you before a call that touches every site.

### Why does start_preloader say the preloader is disabled?

The preloader module is off by default on a new install, and the site refuses to start a crawl until it is on. The agent can switch it on with update_settings on the preloader module, or you can turn it on in the xSpeed Cache panel in wp-admin. Page caching also has to be on, because the crawl exists to fill that cache.

### What does the preloader actually warm?

It reads the site's sitemap, which is the WordPress one at /wp-sitemap.xml unless you set a different sitemap URL, follows nested sitemap indexes and skips any URL your cache exclusion rules leave out. If the sitemap cannot be read, the site falls back to a list built from its own content and says so. If nothing at all is queued, the call reports an error with the reason.

### Can I warm every site with one prompt?

Yes. The agent passes site: "all" to start_preloader and the Hub starts the crawl on every site in the workspace one after another, returning a result per site. The Hub tells the agent to confirm that with you once first. The call only starts the crawls, so progress is read afterwards with get_preloader_status, one site at a time.

### Will warming slow my site down?

A crawl fetches your own pages, a few per run, so it adds load while it runs. The Pages per run setting controls how many, from 1 to 50 with a default of 5. If a site struggles, stop_preloader ends the crawl and the pages already warmed stay cached.

### Why do some pages fail with HTTP 403 or 406?

Those codes are what bad-bot firewall rules usually answer with, and they mean the warmer was judged by its user-agent, not that the page is missing. The warmer identifies itself as xSpeed-Warmer/1.0. Allow that user-agent in the server rule, or change it with the xspeed_preloader_user_agent filter, and run the crawl again.

### Can the agent keep my cache warm on a schedule?

The preloader has its own Schedule setting in WordPress: manual, hourly, daily or weekly. An agent can change it with update_settings. The Hub itself has no scheduler for agent prompts, so a prompt only runs when you send it or when your AI client runs it on a timer.

## Warm the cache with other agents

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

## More with Codex

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

## Documentation

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