WP Manifestindependent plugin directory
manifest / performance / wp-torwald45-purgegate

Czyszczenie Cache Strony

WP mu-plugin: purge nginx FastCGI cache and Cloudflare cache by hostname from the admin bar

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/synchronicity-one/wp-torwald45-purgegate/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Must-use plugin for WP sites served by nginx with FastCGI cache and optionally proxied by Cloudflare. Adds a "Wyczysc cache" button to the admin bar and WP-CLI commands that purge:

  1. the nginx FastCGI cache of the site (files are deleted, directories kept),
  2. the Cloudflare cache of the site hostname(s) - by hostname, never "purge everything", so other sites in the same zone are untouched.

nginx is purged first, then Cloudflare, so Cloudflare refetches pages that are already fresh at the origin.

Requirements

  • The nginx cache directory is shared with the PHP container (for example a named volume mounted in both) and its files are owned by the PHP user.
  • Cloudflare (optional): an API token with the single permission Zone > Cache Purge, limited to the zone of the site. Never a Global API Key.

Installation

Copy torwald45-purgegate.php to wp-content/mu-plugins/ and add to wp-config.php:

define( 'TORWALD45_PURGEGATE_NGINX_DIR', '/var/cache/nginx/fastcgi' );
// Optional - Cloudflare:
define( 'TORWALD45_PURGEGATE_CF_ZONE', 'ZONE_ID' );
define( 'TORWALD45_PURGEGATE_CF_TOKEN', 'API_TOKEN' );
// Optional - default is the host of home_url():
define( 'TORWALD45_PURGEGATE_CF_HOSTS', 'HOST1,HOST2' );
// Optional - default is manage_options:
define( 'TORWALD45_PURGEGATE_CAP', 'manage_options' );

WP-CLI

wp torwald45-purgegate status   # configuration check, Cloudflare token verify
wp torwald45-purgegate purge    # full purge

Safety

  • Only users with the configured capability see the button; the request is protected by a nonce and rate limited (one purge per 10 seconds).
  • The cache directory is resolved with realpath and refused when it points to a system directory or to the WP installation itself. Symlinks are not followed.
  • Every purge is written to the PHP error log with the marker [torwald45-purgegate], including the user and the result.
  • Action torwald45_purgegate_done fires after every purge with the result.

License

GPL-2.0-or-later