Docs cipi.yml Web panel API MCP Ecosystem Guides Compare GitHub Telegram channel
  1. Home
  2. Guides
  3. Cache WordPress with Cipi, layer by layer
PHP, WordPress & e-commerce

Cache WordPress with Cipi, layer by layer

Make a WordPress or WooCommerce site fast on your own server — Nginx's page cache on disk or in memory, purges of only what changed, campaign links cached as one page, and an object cache on a Valkey of its own. Each layer in one command, and how to check it.

By Updated 14 min read

A WordPress page is expensive to build. PHP starts, WordPress loads its plugins and theme, and MariaDB answers dozens of queries — the same options, the same menus, the same posts as for the visitor a second ago. Caching is not doing that work again. On a Cipi server it comes in layers, each for a different visitor, each turned on with one command.

LayerKeepsForTurn it on
OPcachePHP's compiled codeEvery request — PHP still runsOn already
Page cacheThe finished HTML page, on disk or in memoryVisitors who are not signed in: answered by Nginx, without PHPsudo cipi cache blog on
Cipi Cache plugin— it purgesAn edit shows up at once, the rest of the site stays cachedFrom WordPress
Object cacheWhat WordPress asks MariaDB: options, posts, terms, metadata, transientsWhat the page cache never answers: /wp-admin, signed-in users, the cart and the checkout, the first visit to a pagesudo cipi cache blog object on

The app is called blog here: a WordPress custom app, set up as in Host WordPress on your own VPS, with HTTPS on. The commands run on the server as sudo cipi …; those of WordPress, as the app's user (ssh blog@your-server).

1. Turn on the page cache#

bash
sudo cipi cache blog on
✓ Page cache on for 'blog' — pages kept 10m, up to 256m on disk

Nginx now keeps each page PHP makes for a visitor who isn't signed in, and answers the next visitors with it — about a millisecond, PHP never starts. Ask for the same page twice and look at the header Cipi adds:

bash
curl -sI https://blog.example.com/ | grep -i x-cache-status
X-Cache-Status: MISS
curl -sI https://blog.example.com/ | grep -i x-cache-status
X-Cache-Status: HIT
X-Cache-StatusMeans
MISSNot kept yet: PHP made it, and it is kept now
HITAnswered from the cache, without PHP
BYPASSNever cached, on purpose: a signed-in user, the admin, a cart…
EXPIREDKept, but older than its time: PHP made it again

What is never cached, with nothing to set up: a signed-in user or a visitor with a password-protected post open, a commenter, a WooCommerce cart (its cookies), /wp-admin, wp-login.php, the REST API, POST requests, URLs with a query string — except the links of a campaign — and every response PHP marks private. The dashboard works as before; editors never see a cached page. The full list: what is never cached.

A deploy run by Cipi empties the cache by itself. To empty it by hand: sudo cipi cache blog clear — immediate however many pages there are: the folder is swapped for an empty one at once, and the old pages are deleted afterwards at the lowest priority.

2. Choose how long, how much and where#

bash
sudo cipi cache blog ttl 1h        # how long a page is kept: 30s, 10m, 1h, 7d
sudo cipi cache blog size 512m     # how much room the pages may take
sudo cipi cache blog storage       # on disk or in memory, now

How long. Without a purge on change, the time is how long an edit takes to show up: 10 minutes is the default, and fine for most sites. With the plugin of the next step, pages can be kept for hours.

How much. Past the size, Nginx drops the pages asked for least. sudo cipi cache blog says how many pages and bytes are kept now: when it stays at the size, give it more.

On disk or in memory. A page read often is in RAM already — the kernel keeps the files it reads there — so on a fast disk, memory adds little. It pays on a slow or shared disk: a small VPS, network storage, a disk where every MISS is a write that waits next to MariaDB's.

bash
sudo cipi cache blog storage memory
✓ The page cache of 'blog' is in memory — a tmpfs of 320 MB, empty now and after a reboot
On disk (the default)In memory
Where/var/cache/nginx/cipi/blogA tmpfs of the app's own, mounted on the same folder
RAMNone of its ownThe size and a quarter more: 256m is 320 MB at most, used only as pages are kept
After a rebootThe pages are still thereEmpty: cached again as visitors come
EmptyingA rename, then the old pages deleted in the backgroundThe pages deleted in RAM, at once
ForMost serversA disk that makes MISS slow
Page cache settings in the panel with Keep the pages set to In memory: a tmpfs of its own of 320 MB at most on a server with 4,096 MB, every cache in memory may take 1,024 MB together and the other caches take 128 MB; empty after a reboot Page cache settings in the panel with Keep the pages set to In memory: a tmpfs of its own of 320 MB at most on a server with 4,096 MB, every cache in memory may take 1,024 MB together and the other caches take 128 MB; empty after a reboot

The same choice is in the panel — the app's Cache tab, Keep the pages — with the RAM it takes said before saving. Nothing else changes: the same folder, the same purge, the same plugin. Every cache Cipi keeps in memory — the page caches and the object caches of all apps together — may take a quarter of the server's RAM: on a server with 4 GB, about 1 GB. A size past it is refused with the numbers, and a server under 2 GB or without swap is said. Back on disk: sudo cipi cache blog storage disk. More in on disk or in memory.

Start on disk and look at X-Cache-Status for a while. If pages are HIT and the site is still slow for signed-in users or in the shop, the object cache helps more than memory for the pages.

3. Purge only what changed#

The Cipi Cache plugin tells Nginx which pages to drop when something changes in WordPress. Update a post and its own page goes, with its categories and tags, its author's archive, the home page, the feeds and the sitemaps — and nothing else: the rest of the site stays cached.

bash
ssh blog@your-server
cd ~/htdocs
wp plugin install https://github.com/cipi-sh/cache-wp/releases/latest/download/cipi-cache.zip --activate
wp cipi-cache status

Or upload cipi-cache.zip under Plugins → Add New → Upload Plugin. There is nothing to configure: Tools → Cipi Cache → Check the connection says whether it reaches Cipi, and The page cache, on the same screen, how the server caches the site — on or off, how long a page is kept, on disk or in memory — with the command that changes each. A page a plugin marks DONOTCACHEPAGE (a form with a one-time token, a page made for one visitor) stays out of the cache. The toolbar gets Purge this page, the list of posts Purge from cache.

Now an edit no longer waits for pages to expire, so keep them much longer:

bash
sudo cipi cache blog ttl 8h

Pages of your own, by hand, from the server or the panel: sudo cipi cache blog purge /hello-world/ '/category/news/*'. Everything the plugin purges, and when: the WordPress plugin.

4. Campaign links: cached as one page#

A newsletter, an ad or a social post adds parameters to the link — ?utm_source=newsletter, ?gclid=…, ?fbclid=…. They change nothing in the page, but fbclid and gclid are different at every click, so a cache keyed on the address would make every click a MISS: the traffic of a campaign, the moment a site most needs its cache, would all reach PHP.

Cipi keeps a link that carries only such parameters as one copy for all of them, next to the page without parameters:

bash
curl -sI 'https://blog.example.com/?fbclid=AAA' | grep -i x-cache-status
X-Cache-Status: MISS
curl -sI 'https://blog.example.com/?fbclid=BBB' | grep -i x-cache-status
X-Cache-Status: HIT
curl -sI 'https://blog.example.com/?utm_source=newsletter&utm_medium=email' | grep -i x-cache-status
X-Cache-Status: HIT

There is nothing to turn on. A link with any other parameter — ?s=, ?color=red, ?page=2 — still reaches PHP. Google Analytics, the Meta pixel and WooCommerce's order attribution read the parameters in the browser, so they count the campaign as before.

One copy serves every click. A landing page that writes a parameter's value into its HTML on the server — a lead form with the gclid in a hidden field, filled in by PHP — would show the first click's value to the others. Keep it out: sudo cipi cache blog exclude add '/landing/*'. The list of parameters and the reasons: links of a campaign.

5. Turn on the object cache#

The page cache doesn't help a signed-in editor, a customer with a cart, or the first visit to each page: WordPress runs, and asks MariaDB the same things at every request. An object cache keeps those answers in memory between requests. Fewer queries, a faster /wp-admin, and a database that stops being the bottleneck when a shop gets busy.

bash
sudo cipi cache blog object on
✓ Object cache on for 'blog' — a Valkey of its own, 64mb at most; WP_REDIS_* written in wp-config.php
  One step in WordPress: Plugins → Add New → Redis Object Cache → Install, Activate; then Settings → Redis → Enable Object Cache

What Cipi did:

A Valkey of the app's owncipi-valkey@blog, on 127.0.0.1 with a port and a 40-character password of its own, in the same systemd sandbox as a Laravel app's instance
A cache profileA memory limit (64 MB unless you say), the keys used least recently going first when it is full, nothing saved to disk
Six lines in wp-config.phpThe WP_REDIS_* constants of the plugin Redis Object Cache, between two lines Cipi writes and removes
php
/* BEGIN Cipi object cache — managed by `sudo cipi cache blog object`, do not edit */
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6402 );
define( 'WP_REDIS_PASSWORD', '…' );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
/* END Cipi object cache */

Then the one step in WordPress: Plugins → Add New, search Redis Object Cache, Install and Activate; then Settings → Redis → Enable Object Cache. The plugin reads Cipi's lines — there is nothing to fill in — and installs its drop-in, wp-content/object-cache.php. From WP-CLI, the same:

bash
ssh blog@your-server
cd ~/htdocs
wp plugin install redis-cache --activate
wp redis enable
wp redis status

Check it from the server:

bash
sudo cipi cache blog object

Object cache — blog
  on   Valkey of its own, 64mb at most  (cipi-valkey@blog.service, 127.0.0.1:6402, nothing saved to disk)
  Now: 812 key(s), 3.21M, 94.7% of the reads found
  wp-config.php: WP_REDIS_* written (/home/blog/htdocs/wp-config.php)
  WordPress: the Redis Object Cache drop-in is installed

Reads found is the share of WordPress's questions answered from memory since the instance started. It starts low and climbs as the site is used: on a site that has run for a while, most reads are found.

How much memory#

Start with the default and look again after a day of normal traffic. If Memory used is at the limit and keys are being evicted (evicted in sudo cipi cache blog object --json), give it more — the instance keeps what it holds:

bash
sudo cipi cache blog object memory 256mb
✓ The object cache of 'blog' may take 256mb — what it holds stays

16 MB to 8 GB, counted with the page caches in memory in the same quarter of the server's RAM. A blog rarely needs more than the default; a shop with a large catalogue or many signed-in customers fills more.

Why it is safe#

wp-config.php stays the app's fileCipi reads and writes it as the app's user, never as root: the new text next to it under a hidden name Nginx won't serve, the same mode, checked with php -l, then put in place in one rename. A wp-config.php that is a link is refused
No shared instanceWordPress's Flush Cache empties this site's keys and nobody else's; no app can reach another's Valkey
The password stays on the serverIn wp-config.php and the instance's configuration only — never in a command line, a log, a notification, or an answer of the API or the panel
Your own settings win, so Cipi asksA WP_REDIS_HOST (or port, password, cluster, WP_REDIS_CONFIG, WP_REDIS_DISABLED…) that the file already defines is refused with its name, rather than written over

When something needs a change first, Cipi refuses and changes nothing: no WordPress found, a constant of your own, no place to write in the file, not enough RAM. Each message says what to do — the table is in when Cipi refuses.

Empty it, or turn it off#

WordPress keeps its object cache up to date by itself when content changes through it. Empty it after changing the database behind WordPress's back — an SQL import, a search-replace with a tool that doesn't flush:

bash
sudo cipi cache blog object flush
✓ Object cache of 'blog' emptied — 812 key(s); WordPress fills it again as pages are asked for

To stop using it: sudo cipi cache blog object off. Cipi's lines leave wp-config.php — the file is as it was — and the instance and its memory go. While the plugin's drop-in is still in wp-content, the lines say WP_REDIS_DISABLED instead, so WordPress doesn't knock at a Valkey that is gone: disable the object cache in Settings → Redis (or deactivate the plugin), then run off once more.

6. Do it from the panel#

The app's Cache tab in the web panel has every step of this guide:

CardWhat it has
Page cacheOn and off; how long a page is kept and how much room; Keep the pages On disk or In memory, with the RAM the tmpfs takes, the server's RAM and what the other caches take; the pages kept now; Empty the cache now and Purge some pages; the paths of your own that are never cached; how to install the Cipi Cache plugin
Object cache · WordPressTurn the object cache on with the Memory of its Valkey; then Keys, Memory used and Reads found, Empty it now, Turn off. A badge says where it stands: On — one step in WordPress until the drop-in is there, then On — WordPress uses it. A constant of the site's own, another plugin's drop-in, a Valkey that stopped: each is said, with what to do
Object cache card of a WordPress app in the panel: On — WordPress uses it; its keys, the memory used of 128 MB and 92.9% of the reads found; the memory of its Valkey, Save, Empty it now and Turn off; no password goes through the panel Object cache card of a WordPress app in the panel: On — WordPress uses it; its keys, the memory used of 128 MB and 92.9% of the reads found; the memory of its Valkey, Save, Empty it now and Turn off; no password goes through the panel

Turning a cache on or off takes Edit on the app; emptying either comes with Deploy too. The panel runs the same commands with the same checks — there is nothing it can skip.

7. WooCommerce#

Everything above applies to a shop, and the object cache matters most there: the cart, the checkout, the account pages and the orders screen are never in the page cache, and each of them runs WooCommerce's queries.

Cart, checkout, accountNever cached once a visitor has a cart (its cookies), and WooCommerce marks those pages private. To pin their addresses too: sudo cipi cache shop exclude add '/cart*' '/checkout*' '/my-account*'
Prices and stockThe Cipi Cache plugin purges a product's pages when it is saved. After a bulk import or a price update outside WordPress: sudo cipi cache shop clear and sudo cipi cache shop object flush
Object cache memoryStart at 128mb or 256mb for a large catalogue, then watch Memory used and evictions
Background jobsAction Scheduler needs a real cron: see WooCommerce on a VPS

8. Check that it all works#

CheckHowExpect
A public page is cachedcurl -sI <page> twiceMISS, then HIT
An editor is never served a cached pageThe browser's developer tools on a page, signed inBYPASS
An edit shows upUpdate a post, open it in a private windowThe new text: the plugin purged it
Campaign links share one copycurl -sI '<page>?fbclid=A', then ?fbclid=BMISS, then HIT
The object cache is usedsudo cipi cache blog objecton, the drop-in installed, reads found climbing
WordPress sees itSettings → RedisConnected

Automate it#

The same settings, from your own tools:

FromPage cacheObject cache
cipi-clicipi-cli cache on blog --ttl 8h --storage memorycipi-cli cache object on blog --memory 128mb
PHP SDK$cipi->cache()->enable('blog', ttl: '8h', storage: 'memory')$cipi->objectCache()->enable('blog', '128mb')
APIPUT /api/apps/blog/cache — {"enabled": true, "storage": "memory"}PUT /api/apps/blog/cache/object — {"enabled": true, "memory": "128mb"}
A deploy recipe of your ownsudo /usr/local/bin/cipi-cache-clear blog—

The API routes, their abilities and what they answer: page cache and WordPress object cache. No answer ever carries the instance's password.

Troubleshooting#

ProblemFix
Always MISSThe page sends a cookie or Cache-Control: private for everyone — often a plugin starting a PHP session. curl -sI <page> shows the headers
Always BYPASS in the browserYou are signed in, or have a cart or a comment cookie: try a private window
An edit doesn't show upInstall the Cipi Cache plugin, or sudo cipi cache blog purge <path>
storage memory refusedThe caches in memory would take more than a quarter of the RAM: a smaller size, less object cache memory, or stay on disk
Redis Object Cache says Not connectedsudo cipi cache blog object: the instance must be running and wp-config.php must have Cipi's lines. A WP_REDIS_HOST of your own elsewhere in the file wins over them
… defines WP_REDIS_HOST itselfRemove your own WP_REDIS_* lines, then sudo cipi cache blog object on
Another drop-in in the panelwp-content/object-cache.php is another plugin's: turn that object cache off in WordPress, then enable Redis Object Cache's
Redis Object Cache complains after object offIts drop-in is still in wp-content: disable the object cache in Settings → Redis (or deactivate the plugin), then sudo cipi cache blog object off once more takes Cipi's last line away

Questions

Is this the same as the cache stack of a managed WordPress host?

The same pieces: Nginx's page cache, a plugin that purges what a change touches, and an object cache on Redis — here Valkey, which speaks the same protocol. The difference is where the settings live: on the server, under sudo cipi cache. A compromised plugin can purge its own site's pages; it can never change the rules or reach another site's cache.

Do I still need WP Rocket, W3 Total Cache or LiteSpeed Cache?

Not for pages: Nginx answers them before PHP starts, which no plugin can do. A plugin you keep for minifying or lazy-loading assets is fine — turn its own page cache off, so two caches don't keep the same page.

Redis or Valkey?

Valkey is the open-source continuation of Redis, with the same protocol. The plugin Redis Object Cache connects to it exactly as to Redis, through the phpredis extension Cipi installs with every PHP.

How much RAM does all this take?

The page cache on disk takes none of its own. In memory, it takes its size and a quarter more; the object cache takes its memory limit, 64 MB by default. Together, the caches Cipi keeps in memory may take a quarter of the server's RAM — Cipi refuses more, with the numbers.

Does a reboot lose anything?

The pages in memory and the object cache are empty after a reboot, and are rebuilt as visitors come. Nothing in either is data: posts, orders and settings stay in MariaDB.

Does it work with Bedrock?

Yes. Cipi looks for wp-config.php in the folder the app is served from and in the one above it, and writes its lines right above the one that loads wp-settings.php when the file has no "That's all, stop editing!" line.

What about Object Cache Pro?

Cipi writes the lines of Redis Object Cache. Object Cache Pro is configured through WP_REDIS_CONFIG: with it in wp-config.php, Cipi refuses to write rather than mix the two, and says so.

Can I do all this without the terminal?

Yes: the app's Cache tab in the web panel turns on the page cache, chooses disk or memory, and turns on the object cache with its memory. The step inside WordPress is from the dashboard.

Try it on your own server

Free and open source. One command on a fresh Ubuntu 24.04 or 26.04 VPS.

wget -O - https://cipi.sh/setup.sh | bash
Read the quickstart