WP Manifestindependent plugin directory
manifest / performance / w3tc-flush-reprime

W3TC Flush Re-prime

Re-primes the page cache for anything W3 Total Cache purges. Listens to W3TC's public flush actions (any plugin, any trigger), then fires non-blocking loopback requests AFTER W3TC has executed its queued purges, so the next visitor gets a cached page instead of paying the regeneration cost.

★ 0stars
1.0.0latest · 3mo ago

Install

Download w3tc-flush-reprime-1.0.0.zip From the 1.0.0 release on GitHub, Jul 7, 2026

Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/robwent/w3tc-flush-reprime/releases/download/1.0.0/w3tc-flush-reprime-1.0.0.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Re-primes the page cache for anything W3 Total Cache purges.

When W3TC purges a page — because a post was saved, an importer updated it, or a plugin called w3tc_flush_post() / w3tc_flush_url() — the next visitor to that URL pays the full regeneration cost. This plugin listens to W3TC's public flush actions and fires a non-blocking loopback request to each purged URL, so the page is back in the cache before a real visitor arrives.

Why timing matters

W3TC does not delete cache files when a flush is requested. It queues the purge and executes it on shutdown at priority 100000 (see W3TC's CacheFlush.php). A loopback request fired inline — the obvious implementation — is served the old cached page, which W3TC then deletes moments later, leaving the URL uncached anyway.

This plugin queues purged URLs as the flush actions fire and requests them on shutdown at priority 200000 — after W3TC has actually deleted the files. Queueing also dedupes: a bulk import that flushes the same page fifty times in one request primes it once.

What gets primed

  • Posts purged via w3tc_flush_post (published posts only — permalinks are resolved at flush time, so posts being deleted are skipped naturally).
  • URLs purged via w3tc_flush_url.

Deliberately not primed:

  • Full flushes (w3tc_flush_all / w3tc_flush_posts) — nothing sane to prime.
  • Purge-policy side effects (archive pages, feeds, sitemaps) — rebuilt on next visit/crawl.

Installation

Install as a normal plugin (upload the folder to wp-content/plugins/ and activate), or drop the PHP file straight into wp-content/mu-plugins/ — it has no activation hooks, no settings, and stores no data, so both work.

Requires W3 Total Cache with page caching enabled. Harmless if W3TC is inactive (the hooks simply never fire).

Filters

// Disable priming without deactivating the plugin.
add_filter( 'w3tc_flush_reprime_enabled', '__return_false' );

// Cap the number of loopback requests fired per process (default 100),
// so a runaway bulk purge can't fan out hundreds of requests.
add_filter( 'w3tc_flush_reprime_cap', fn () => 25 );

License

GPL-2.0-or-later

Releases

1 release. Each count is every asset in that release; expand a row for the breakdown.

Tag
Published
Assets
Downloads
1.0.0 latest
Jul 7, 2026 3mo ago
w3tc-flush-reprime-1.0.0.zip
0