Skip to content

Purging and refresh

Shane Rounce edited this page Nov 30, 2026 · 4 revisions

Purging and refresh

A cache is only as good as the way it lets go of old pages. Ace Redis Cache prefers to refresh a page in place over deleting it: the old copy keeps being served until the new one is ready, so nobody is sent to a cold render.

Three ways a page leaves the cache

Action What happens Use it for
Refresh The stored copy is marked stale and kept. A background render replaces it when complete. Content you know has changed
Soft purge Every page is marked stale at once. Each is refreshed in the background. Deploys, imports, anything site-wide
Purge The stored copy is deleted. The next visitor waits for a full render. Content that must not be shown again

Refresh and soft purge rely on the grace window (3600 seconds by default). A site with the grace window set to 0 cannot serve stale pages, so both fall back to deleting.

What an edit does

Saving, publishing or unpublishing a post queues a recache. It works wherever the save came from: the block editor, wp-admin, the REST API, WP-CLI or cron.

You edit What is refreshed
A post or page Its own URL, the home page, the posts page, its post type archive, its term archives, and for posts the author archive
A synced pattern Every published post that uses it, traced through patterns that include it
A template, template part, navigation menu or global styles The whole site (soft purge)
A WooCommerce product, variation or stock level The product, its listings and any composite product that offers it
A product attribute or one of its terms The whole site

Only pages that already have a stored copy are refreshed. Nothing is rendered that no visitor asked for.

The queue is worked by cron, so make sure WP-Cron or your system cron runs. Up to 100 URLs are refreshed per edit (aceredis_recache_max_urls).

Turn the whole behaviour off with:

add_filter( 'aceredis_recache_on_edit', '__return_false' );

Changing what an edit refreshes

add_filter( 'aceredis_recache_urls', function ( $urls, $post ) {
	if ( 'event' === $post->post_type ) {
		$urls[] = home_url( '/whats-on/' );
	}
	return $urls;
}, 10, 2 );
Filter Changes
aceredis_recache_urls The full list of URLs for an edited post
aceredis_recache_related_urls The listing pages that show the post
aceredis_sitewide_recache_post_types Post types whose edits make the whole site stale
aceredis_post_invalidation_paths, aceredis_post_archive_invalidation_paths Paths purged for a post and its archives
aceredis_enable_cache_priming Return false to mark pages stale without rendering them now. Useful during bulk imports.

Refreshing pages from your own code

When your plugin knows exactly which pages changed, say so:

aceredis_refresh_urls( array(
	home_url( '/fixtures/' ),
	home_url( '/results/' ),
) );

Desktop and mobile copies are both refreshed. It returns the number of refreshes queued, or false when the page cache is not running. Pass false as the second argument to mark the pages stale without rendering them straight away.

Soft purge

aceredis_soft_purge_page_cache();

Every stored page now counts as stale. Visitors and crawlers keep getting stored copies while the refresher works through them one at a time.

Calls made within five minutes of the last soft purge are folded into a single one at the end of that window (aceredis_soft_purge_min_interval), so an import that calls it a hundred times does not keep the site re-rendering all day. A deploy should not wait:

aceredis_soft_purge_page_cache( true );

It returns false when a soft purge is not possible, and you should purge instead.

Purging one URL

do_action( 'aceredis_cache_purge_url', home_url( '/pricing/' ) );

That deletes every stored copy of the page, including the ones the early-serve drop-in reads.

  • Purging a clean path also removes its recorded query-string variants.
  • Purging a URL with a meaningful query string removes that exact variant.
  • Tracking parameters are ignored.

Keys are deleted one per command, so this works on cluster-mode servers.

Clearing everything

  • Clear All Cache on the settings screen.
  • Clear Redis Cache in the admin toolbar.
  • POST /wp-json/ace-redis-cache/v1/flush-cache as an administrator.

From 0.11.1, a site page flush removes the stored page timestamps along with the pages. The same cleanup runs when Redis comes back after an outage.

Saving the settings also clears the cache, with one exception: a save that only changes block cache settings retires block entries and leaves pages alone.

On a busy site, prefer a soft purge. A full clear means every next request is a full render.

Warming

After pages are purged the plugin can render them again before a visitor arrives. Warm requests go to your own site's public URLs and carry an X-AceRedis-Prime header so they are rendered fresh and stored.

The optional warmer checks for missing desktop page entries and passes their URLs to the background refresher. Enable Caching > Cache warming > Keep pages warm to schedule it. With the defaults it checks 40 URLs every ten minutes, working through the home page, archives, terms and the newest posts. The cursor carries on from the previous batch. A load average above 4 pauses the check.

Use aceredis_warm_urls to change the list and aceredis_warm_paused to pause scheduled or manual checks. The settings reference lists the limits. To check the cursor or run a batch now, see WP-CLI.

With Prioritise popular posts when Ace Popular Posts is active enabled, ARC reads the aggregate counts already held by Ace Popular Posts. A batch of eight can check up to two ranked, eligible URLs. The ordinary list supplies the other slots, or the whole batch if the companion is unavailable. ARC does not start recording visits. The most recent run reports last.popular_checked in wp aceredis warm status --format=json.

On WooCommerce sites the best-selling products (20 by default) are warmed after a clear.

Filters for tuning the refresher: aceredis_prime_parallel, aceredis_prime_timeout, aceredis_prime_time_budget and aceredis_prime_continue_delay.

Hooks that fire on a purge

Action When
aceredis_paths_invalidated Specific paths were purged. Receives the paths.
aceredis_cache_cleared Everything was cleared
aceredis_page_epoch_bumped A soft purge marked every page stale

Use them to tell another layer, such as a CDN, about the change. The built-in Varnish integration is written on exactly these.

Clone this wiki locally