# Clear all caches

> Clear the page, object, PHP code, and CDN caches in one click from WordPress, the dashboard, WP-CLI, or the API. Also scheduled purges, statistics, and history.

Source: https://docs.wpwaterfall.com/clear-caches

WP Waterfall keeps four caches for each environment. **Clear all caches** empties all four in one step:

- **Page cache.** Whole pages the server keeps for visitors who are not logged in.
- **Object cache.** The Redis cache of the object cache add-on, when the site has it. Each environment has its own Redis, so this touches no other site.
- **PHP code cache.** PHP's compiled code (OPcache). On live, code is a read-only release, so this is the only code cache there is.
- **CDN cache.** Cloudflare's copies of your pages and files, for every domain of this environment.

Clearing a cache never deletes content, settings, users, or orders. Transients are only gone when the object cache held them, which is where WordPress keeps them when the object cache add-on is on. Pages and objects rebuild on the next visit.

## From WordPress

Users who can manage options (administrators) see **Clear caches** in the admin bar, in wp-admin and on the front end of the site.

- Click **Clear caches** itself, or **Clear all caches** in its menu, to clear all four.
- **Clear page cache**, **Clear object cache**, and **Clear CDN cache** clear one at a time.

When it is done, the admin bar menu shows what happened, for example: "Cleared: page cache, object cache, PHP code cache, CDN cache (clears in a few seconds)." WordPress never shows a banner for it. If a cache could not be cleared, the line says which one and why, and the others still clear. If the agent on the server does not answer, WordPress skips the CDN cache and says so; use **Clear all caches** in the dashboard. For example, a site without the object cache add-on shows "Skipped the object cache: this site has no object cache, so nothing was stored there."

**Tools > WP Waterfall Cache** is a simple page with one section for each job:

- **Cache Control** has **Clear All Caches**.
- **Site Caching** has **Clear Site Cache**.
- **Object Caching** has **Clear Object Cache**.
- **CDN Caching** has **Clear CDN Cache**.
- **Settings** has **Enable Autopurge**, **Clear all caches when content is saved**, **Front end defaults**, and **Save Settings**.
- **Need Help** has **Go To Dashboard**.

After you click a button, the result shows as a line in that section.

### Autopurge

WP Waterfall clears the cache for you when your content changes: when you publish, update, trash, or delete a page or post, when a comment is approved, when you save a menu, the Customizer, or a widget, when you switch a theme or turn a plugin on or off, and when WordPress, a plugin, or a theme updates. A post's archives clear with every page under them, so page 2 of a category never shows an old list. Archives clear at most once every 10 seconds, so a run of saves does not clear them again and again. A change that comes inside those 10 seconds clears its archives the moment the 10 seconds are up, even when nobody visits the site, and the edge copies go at the same moment as the server copies. A new WooCommerce product, for example, shows on the shop page and its category pages a few seconds after you publish it.

It also clears when a change reaches a page without a post save:

- A WooCommerce stock or stock status change clears the product page. For a variation, it clears the parent product.
- An ACF options page save, or an Elementor cache clear or maintenance mode change, clears every page.
- A change to a site setting that shows on every page clears every page. That covers the site title and tagline, the date and time formats, the language and time zone, the permalink structure, the front page and posts page settings, the posts per page, the site icon, and the comment settings.
- Rewrite and republish in Yoast Duplicate Post clears the original post.

Several changes in one request cause one purge. Autopurge does not clear the object cache unless **Clear all caches when content is saved** is on (below). **Clear Object Cache** and **Clear All Caches** always do. A developer can switch off one kind of trigger with the `wpwaterfall_autopurge_trigger` filter, and change the list of settings with `wpwaterfall_autopurge_options`.

Turn off **Enable Autopurge** while you import many posts, then turn it back on. While it is off, nothing clears on its own, so click **Clear All Caches** when the import is done.

### Clear all caches when content is saved

Turn on **Clear all caches when content is saved** in **Settings** when you would rather clear everything than only the pages a change touches, for example on a shop whose products show in many places. Then every change autopurge handles (publishing, updating, trashing, or deleting any post, page, or product, a stock change you make, a menu, the Customizer, a widget, a site setting, and the other triggers above) clears the page cache, the object cache when the site has the object cache add-on, and the whole CDN cache. It does not reset PHP's code cache, because saving content changes no code.

Only a change by someone allowed to make it clears everything: a signed-in user who may edit that content, a WP-CLI command, or a scheduled post going live. A change a visitor causes clears only its own pages, as when the setting is off. That covers a comment from a visitor, even one WordPress approves on its own, a pingback or trackback, and a stock change from a customer's order, which still clears that product's page right away. So nobody outside your team can empty every cache of your site by posting comments.

It clears at most once every 10 seconds. A save inside those 10 seconds is held and cleared the moment they are up, so an import of many posts clears a few times, not once per post. The setting is off by default and works only while **Enable Autopurge** is on. With WP-CLI: `wp option update wpwaterfall_autopurge_clear_all 1` turns it on, and `wp wpwaterfall cache status` shows both settings.

### How fast the CDN cache clears

The CDN cache clears in a few seconds. WordPress never holds your Cloudflare credentials. The plugin asks the WP Waterfall agent on your server, the agent tells WP Waterfall at once, and WP Waterfall clears Cloudflare for every domain of the environment. The request is checked against a secret only your site and its server know. If that message is lost, WP Waterfall still finds the request within 30 seconds, because it also checks every server for waiting requests that often.

You can ask for the CDN cache once every 10 seconds. A second click sooner says "Already clearing the CDN cache. Try again in a few seconds." Each edge clear from WordPress is in **User Activity** as "Cleared all caches from WordPress" with the email of the WordPress user who asked, and in the purge history on **Caching**.

## Staging and preview environments

Staging and preview environments have no page cache and no CDN cache. The server keeps no page cache there and Cloudflare keeps no copy of a page or a file, so every change shows at once. The object cache add-on still runs there when the site has it. Every answer says `x-wpwaterfall-cache: BYPASS` and `x-wpwaterfall-cache-reason: staging`. This does not depend on the search engine setting.

On staging, preview, and local sites, WordPress shows no cache controls. The admin bar has one item, **Cache**. Hover it and it says that caching is off, so every page shows your latest changes. There is no **Tools > WP Waterfall Cache** page there, and the site's Info page in the dashboard says nothing about caching.

## From the dashboard and AI agents

**Caching > Clear all caches** in the dashboard clears the same four caches, and so does the `clear_cache` tool for AI agents when you give it no paths. Both run one job, and the finished job says what it cleared. With paths, `clear_cache` clears only those pages from the server cache.

## From WP-CLI

```
wp wpwaterfall cache clear            # all caches
wp wpwaterfall cache clear --page
wp wpwaterfall cache clear --object --edge
```

`wp cache flush` clears every cache too, the edge cache included, not only the object cache. WP-CLI runs outside the web server's PHP, so it cannot reset PHP's code cache. `wp wpwaterfall cache clear` says so and clears the other three. Use the admin bar or the dashboard when you also need PHP's code cache reset. The command is allowed in the dashboard's WP-CLI tool and through the API.

## How do I schedule a purge?

A scheduled purge clears all caches on a timetable, so a site that changes on a fixed rhythm never serves a page older than the last slot. It is the same purge as **Clear all caches**.

1. Open your site, then **Caching**, then the **Rules** tab.
2. In **Scheduled purge**, choose **Every day** or **Every week**.
3. For a weekly schedule, choose the day. Choose the hour. Hours are in UTC.
4. Select **Save schedule**.

The card then says when the next purge runs. Choose **Off** to stop. A new schedule waits for its next slot, so saving it never purges at once. Each environment has its own schedule.

At the hour you chose, WP Waterfall starts the same purge job that **Clear all caches** starts. It appears in the jobs drawer and in User activity as a purge started by the system. Saving or changing the schedule is its own entry in User activity with your name. A purge for a sleeping environment is skipped, because it has no cache. A server that is offline is tried again within minutes, and one purge runs for each slot, however many times it is tried. Only people who can manage the edge can change the schedule. Everyone who can see the site can read it.

- `GET /v1/environments/{id}/cache/schedule` reads the schedule: `frequency` (`off`, `daily`, or `weekly`), `hour_utc`, `weekday` (0 is Sunday), `last_run_at`, and `next_run_at`.
- `PUT /v1/environments/{id}/cache/schedule` sets it. It needs the `sites:write` scope.
- The MCP tools `get_cache_purge_schedule` and `set_cache_purge_schedule` do the same for a site's live environment.

## Where are the cache numbers and the purge history?

**Cache statistics.** Open **Analytics** and choose the **Cache** tab. It shows hits, misses, and bypassed requests for the period you pick. The numbers come from the server log on your site's server, collected every hour. See [Analytics](https://docs.wpwaterfall.com/analytics).

**Purge history.** Every purge is a job, so it shows in the jobs drawer with its time, who asked for it, and whether it succeeded. That includes purges a WordPress admin started with **Clear caches** in the admin bar. The full list, with scope and URLs, is in the API.

- `GET /v1/environments/{id}/cache/stats`
- `GET /v1/environments/{id}/cache/purges`
- The views `top-cached-paths` and `top-bypassed-paths` of `GET /v1/environments/{id}/analytics/{view}` rank the pages that came from the cache and the pages that skipped it.

## What it does not clear

Clear all caches does not clear the cache of another caching plugin. WP Waterfall blocks page cache plugins that fight the server cache.

## API

- `POST /v1/environments/{id}/cache/purge` with `{"scope": "all"}` clears all four caches. The job result lists them in `cleared`.
- `POST /v1/environments/{id}/tools/cache/clear` clears the server caches (page, object, and PHP code) without Cloudflare, or only the paths you list.

## Related

- [Edge cache and CDN](https://docs.wpwaterfall.com/edge-cache)
- [Object Cache](https://docs.wpwaterfall.com/object-cache)
- [Jobs and progress](https://docs.wpwaterfall.com/jobs-and-progress)
- [Analytics](https://docs.wpwaterfall.com/analytics)
- [Troubleshooting caching](https://docs.wpwaterfall.com/troubleshooting-caching)
