# Set up the Redis object cache with GitHub Copilot in VS Code

> Setting up a Redis object cache with GitHub Copilot in VS Code means asking agent mode to check a site's object cache, test Redis and enable it through xSpeed Hub.

Page: https://xspeedcache.com/agent/github-copilot/object-cache/
Last updated: October 2026

You are in VS Code with Copilot chat in agent mode, probably in the repository of a WooCommerce or membership site where the database is the bottleneck. Type: set up Redis for shop and test the connection before enabling. Copilot calls get_object_cache_status through the xSpeed Hub server and reports the drop-in state, the configured backend and its stats. As with every agent, that read does not show whether Redis answers.

Next comes test_object_cache, run from the site's own server, which reads and writes a probe value and returns the Redis server's error if it cannot. A pass is the point to call toggle_object_cache with enabled set to true, which installs the object-cache.php drop-in. VS Code starts in Manual permissions, which shows a confirmation for each tool call that is not auto-approved, so you see the status and test results in the chat first and decide on the toggle with them in front of you.

What is particular to Copilot is the confirmation scope. The confirmation lets you allow a tool once, for the session, for the workspace or for all future calls, and a broad choice carries over to later calls of the same tool. Chat: Manage Tool Approval lists the tools grouped by MCP server. VS Code also caps a chat request at 128 tools, and the 29 Hub tools count toward that, so with many servers enabled, use the Configure Tools button to check that the four object-cache tools are on before you start. The editor runs on your machine, so the Redis check itself comes from the site through the test tool.

## Set up GitHub Copilot in VS 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 your user mcp.json

Open the Command Palette and run MCP: Open User Configuration, then add this entry. Servers in your user profile are available in every workspace. MCP: Add Server walks you through the same thing, and the project-level .mcp.json file works too if you want the entry shared with your team; that file uses a top-level mcpServers object instead of servers.

File: `mcp.json (MCP: Open User Configuration)`

```json
{
  "servers": {
    "xspeedhub": {
      "type": "http",
      "url": "https://app.xspeedcache.com/xspeed/mcp"
    }
  }
}
```

### 3. Start the server and sign in

Run MCP: List Servers, pick xspeedhub and choose Start. VS Code asks whether you trust the server, then opens a browser page where you sign in to xSpeed Hub and approve access. There is no token to paste, and VS Code keeps the credentials it receives. Open the Chat view and use the Configure Tools button to see the xSpeed tools.

```
MCP: List Servers
```

Full setup: https://xspeedcache.com/agent/github-copilot/

### 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. In VS Code the default permission level is Manual permissions: a tool call that is not auto-approved shows a confirmation, and you can allow it once or for the session, the workspace or all future calls. Chat: Manage Tool Approval lists tools grouped by MCP server, so you can trust get_cache_status and the other reads while purge_cache and update_settings stay on a prompt. Allow all, Autopilot and global auto-approval skip those prompts, including for external tool calls, and then a write runs as soon as your connection allows writes. xSpeed Hub has no confirmation step of its own.

## Prompts

- In agent mode, use xSpeed Hub to check the object cache status on shop and run the Redis test. Stop and show me the results.
- With xSpeed Hub, enable the object cache on shop if the Redis test passes, then read the status again.
- Use xSpeed Hub to flush the object cache on blog, and explain how that differs from purging the page cache.

## Example session

```
You: Using xSpeed Hub, set up Redis on shop and test it before enabling.
  → get_object_cache_status(site: shop) [read-only]: Drop-in not installed. Backend: Redis configured.
  → test_object_cache(site: shop) [read-only]: Connected. Probe value written and read back.
Agent: The test passed. I am about to call toggle_object_cache with enabled: true on shop. Confirm?
You: Confirmed.
  → toggle_object_cache(site: shop, enabled: true) [changes site]: Drop-in installed. Redis active.
Agent: Redis is the object cache on shop. If stale options show up later, flush_object_cache clears this cache without touching the page cache.
```

## How it works

1. **Read the current state**: get_object_cache_status reports whether the object-cache.php drop-in is installed, which backend is configured, Redis or Memcached, and its stats. It does not prove the server answers, so a clean status is not a green light.
2. **Test the connection first**: test_object_cache opens a live connection to the configured server and does a read and write probe with the settings saved on the site. A failure comes back with the server's own reason, such as a wrong password, a refused connection or a permission error. The Hub tells the agent to run this before toggle_object_cache.
3. **Fix the connection if the test fails**: get_settings reads the object-cache module, with secrets masked. update_settings changes it, for example the host or port. On a managed host that defines these values in wp-config.php, the fields are read-only and a write that tries to change one is refused with the name of the constant. For a host that wants the constants pasted, get_object_cache_status with detail set to snippet returns the wp-config.php block.
4. **Turn it on**: toggle_object_cache with enabled true makes the site test the connection again, write the connection constants into wp-config.php and install the object-cache.php drop-in. If the test fails, it stops with "Could not enable" and writes nothing. If wp-config.php is not writable, the drop-in goes in and the reply tells you to add the snippet by hand. The Hub tells the agent to briefly confirm intent first.
5. **Check it took**: The drop-in loads on the next request, so the agent reads get_object_cache_status again after a page load and runs test_object_cache once more. The status also warns when the cache connects but refuses writes, so a connected cache that stores nothing does not pass as healthy.
6. **Flush when stale data survives**: flush_object_cache empties the persistent object cache. Use it when old options, transients or query results outlive a page cache purge. It does not touch the page cache; purge_cache does that.

## Reference

| | |
| --- | --- |
| Read tools | get_object_cache_status and test_object_cache, both work on a read-only connection |
| Write tools | toggle_object_cache (enabled true or false) and flush_object_cache |
| Backends | Redis or Memcached |
| Status detail | status (default) or snippet, the wp-config.php constants block |
| What status proves | Drop-in installed, backend configured, stats. Not that the server is reachable |
| What the test proves | A live connect and a read and write probe on the saved settings, with the server's own error on failure |
| Enable does | Tests the connection, writes connection constants to wp-config.php, installs the object-cache.php drop-in |
| Disable does | Removes xSpeed's drop-in and its wp-config.php block; a drop-in owned by another plugin is left alone |
| Connection timeout | 1 second by default, set in the object-cache module |
| Settings module | object-cache, for get_settings and update_settings |
| Every site at once | None of these tools accept site: "all"; one site per call |
| Confirmation | None on the Hub; your client's prompt is the gate |

## Rules

- Test before you toggle. The Hub tells the agent to run test_object_cache first, because a cache server that does not answer slows every request while the page cache still looks healthy.
- Keep the Redis password out of the chat. get_settings masks it, but the wp-config.php snippet is built from the saved settings and can include a saved password. Set secrets in wp-config.php or in the xSpeed panel.
- toggle_object_cache and flush_object_cache are write tools. The Hub tells the agent to briefly confirm intent for the object-cache toggles, but that is guidance, not a lock. Your client's approval prompt and a read-only grant are the gates that matter. A read-only grant means the connection token with Read-only everywhere on, or a Viewer member's sign-in; an OAuth sign-in gets the scopes the client asks for, which are read and write by default.
- If another plugin owns the object-cache.php drop-in, turn its object cache off in that plugin. xSpeed leaves a drop-in it did not install in place when you disable.
- A flush clears cached data, so the next requests rebuild it from the database and the site is briefly slower. Flush one site, then check it, before you repeat it.

## Good to know with GitHub Copilot in VS Code

When VS Code asks you to confirm toggle_object_cache, pick the one-time option. Allowing it for the session, the workspace or all future calls means later calls to it run without a dialog, and so do Allow all, Autopilot and global auto-approval, which skip prompts for every tool. The Hub runs a write as soon as the connection permits it. The two read tools, get_object_cache_status and test_object_cache, are fine to allow for the session.

## More prompts for this job

They work in any client connected to xSpeed Hub.

- Using xSpeed Hub, is a persistent object cache running on shop, and which backend does it use?
- Use xSpeed Hub to test whether Redis is reachable from shop. Do not change anything.
- Shop is slow in wp-admin. Use xSpeed Hub to check the object cache before anything else.
- With xSpeed Hub, test Redis on shop, and if it passes, turn the object cache on.
- Ask xSpeed Hub for the wp-config.php object cache snippet for docs.
- Use xSpeed Hub to flush the object cache on blog. Old options survive a page cache purge.
- With xSpeed Hub, turn the object cache off on shop and confirm the drop-in is gone.

## Frequently asked questions

### How many xSpeed tools count against the Copilot limit?

xSpeed Hub exposes 29 tools, and four of them handle the object cache: get_object_cache_status, test_object_cache, toggle_object_cache and flush_object_cache. VS Code allows 128 tools in one request, so the Hub fits, but other enabled servers draw on the same budget.

### Which VS Code confirmation should I pick for the Redis toggle?

Allow it once. The session and workspace options keep allowing that tool later without a dialog, and the Hub runs the toggle as soon as your connection allows writes. Allowing the two read tools for the session is fine.

### Why test the connection before turning the object cache on?

Because a cache server that does not answer costs time on every request while the page cache still looks fine. The Hub tells the agent to run test_object_cache first, and the site also tests the connection when you enable and refuses to continue if it fails. The probe is still worth running on its own, since it returns the server's exact reason, such as a wrong password or a refused connection.

### What happens if Redis stops answering after I enabled it?

The site keeps working. The drop-in is built never to take the site down: it falls back to WordPress's own cache for the length of the request and marks itself as degraded. A request can still wait up to the connection timeout, which is 1 second by default, so the site gets slower. xSpeed reports that state as degraded, and test_object_cache names the fault.

### Can the agent install Redis for me?

No. These tools connect xSpeed to a Redis or Memcached server that already exists and switch the object cache on or off. Getting a server is a hosting task. xSpeed uses the phpredis extension when it is there and its own built-in client when it is not.

### What is the difference between flush_object_cache and purge_cache?

flush_object_cache empties the persistent object cache and nothing else. purge_cache with type object does the same job through the purge tool, and purge_cache with type all also clears the page cache and, when connected, the Cloudflare edge. Use the flush when stale options or transients survive a page cache purge.

### Is the wp-config.php snippet safe to share?

Treat it like a secret. The snippet is built from the settings saved on the site, so it can contain the Redis password if one is saved. Paste it into wp-config.php yourself and avoid sharing it in a chat or a ticket.

## Set up Redis object cache with other agents

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

## More with GitHub Copilot in VS Code

- [Purge the WordPress cache with GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/purge-cache/)
- [Find out why WordPress pages are not cached with GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/troubleshoot-cache/)
- [Scan a website for speed problems with GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/speed-scan/)
- [Run and track PageSpeed tests with GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/pagespeed-tests/)
- [Raise a WordPress site's PageSpeed score with GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/optimize-site/)
- [Tune WordPress cache settings with GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/cache-settings/)
- [Warm the WordPress cache with GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/preload-cache/)
- [Manage Cloudflare caching with GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/cloudflare/)
- [Manage every WordPress site at once with GitHub Copilot in VS Code](https://xspeedcache.com/agent/github-copilot/fleet/)

## Documentation

- How to enable Redis or Memcached: https://xspeedcache.com/docs/object-cache/
- How to enable Page Cache: https://xspeedcache.com/docs/page-cache/
- Common problems and troubleshooting: https://xspeedcache.com/docs/common-problems-and-troubleshooting/
