plugin-icon

Proxy Cache Purge

Videz automatiquement le contenu du proxy mis en cache lorsque votre site est modifié.
Note
4.4/5
Version
5.5.3
Installations actives
40K
Mis à jour récemment
Dec 20, 2025
Proxy Cache Purge

Cette extension n’installe pas ni ne configure un proxy de cache. Il sert d’interface avec ces services.

One common method of caching content for websites is via the use of reverse proxy caching. Common examples of this are Varnish and NGINX. These systems allow a website to update content and have the visitor’s experience cached without the need for complex plugins storing the files locally and using up a user’s disk space.

Un cache proxy inversé est installé devant un serveur et examine les requêtes. Si la page demandée est déjà mise en cache, elle fournit le contenu mis en cache. Sinon, elle génère la page et le cache à la demande.

The Proxy Cache Purge plugin sends a request to delete (aka flush) the cached data of a page or post every time it’s modified.

Comment cela fonctionne

Lorsque le contenu d’un site est mis à jour par WordPress, l’extension contacte le service de cache proxy avec l’URL de la page, demandant la suppression du cache.

Not all pages are deleted from the cache on every change. For example, when a post, page, or custom post type is edited, or a new comment is added, only the following pages will purge:

  • La page d’accueil
  • L’article/la page modifié/ée
  • Toutes les catégories, étiquettes et/ou taxonomies personnalisées associées à la page
  • Flux similaires
  • Pages API JSON associées

De plus, votre cache entier sera supprimé lors des actions suivantes :

  • Changement de thème
  • En appuyant sur le bouton Vider le cache dans la barre d’outils

Les extensions peuvent également s’accrocher aux actions de purge, pour filtrer leurs propres évènements afin de déclencher une purge.

Sur un réseau multisite utilisant des sous-dossiers, uniquement les administrateurs et administratrices de réseau peuvent purger le site principal.

Mode de développement

Si vous travaillez sur un site et devez désactiver la mise en cache de l’une des deux façons suivantes :

  1. Ajoutez define( 'VHP_DEVMODE', true ); à votre fichier wp-config.php
  2. Go to Proxy Cache -> Settings and enable Debug Mode for 24 hours at a time

Cela brisera le cache lors du chargement de la page. Ce n’est pas recommandé pour la production !

Cache Tags (BETA)

As of version 5.4.0, Proxy Cache Purge includes an optional Cache Tags / Surrogate Keys purge mode. This feature is marked as BETA and is disabled by default.

When enabled, the plugin:

  • Adds cache-tag headers to WordPress responses (for example, tagging pages by post ID, post type, taxonomy terms, author, and archives).
  • Uses tag-based purges instead of individual URL purges when content is updated, which can reduce purge traffic and improve consistency on complex sites.

Requirements:

  • A proxy cache that supports Cache Tags / Surrogate Keys and advertises this via standard Surrogate-Capability headers (for example, Surrogate-Capability: vhp="Surrogate/1.0 tags/1").

How to enable:

  • Go to Proxy Cache Settings Purge Method and check “Use Cache Tags (Surrogate Keys)”. The checkbox is only enabled when your cache tells WordPress it supports tags (or when you explicitly enable it via a define).
  • Alternatively, you can force-enable or force-disable detection via wp-config.php:

    define( ‘VHP_VARNISH_TAGS’, true ); // Force treat cache as tag-capable define( ‘VHP_VARNISH_TAGS’, false ); // Force treat cache as not tag-capable

Because this feature depends on your cache configuration, it is recommended that you test it carefully in staging before enabling it on production.

Background Purging with WP-Cron

On busy sites, sending many PURGE requests directly from admin requests can slow things down. When you define DISABLE_WP_CRON as true in wp-config.php (because you are running a real system cron that calls wp-cron.php), Proxy Cache Purge automatically switches to an asynchronous mode:

  • Purge requests (both URL-based and tag-based, when Cache Tags are enabled) are collected into a small per-site queue.
  • The queue is processed by WP-Cron in the background, keeping your admin and content-editing actions responsive even when many URLs or tags must be invalidated.

Object-cache purges (the « Purge Database Cache » option) remain synchronous and are not affected by this behaviour. The Proxy Cache settings page and Site Health integration expose basic queue status so you can verify that background purging is healthy; if the queue appears large or very old, check that your system cron is correctly invoking WordPress cron.

Important: Cron Frequency and Cache Freshness

When using background purging, the frequency of your system cron determines how quickly cache invalidations are processed. The longer the interval between cron runs, the longer visitors may see stale content after updates.

For minimal stale content, run your system cron every minute:

* * * * * /usr/bin/php /var/www/html/wp-cron.php

If you can tolerate slightly longer delays, every 2-5 minutes is also acceptable. However, running cron less frequently (e.g., every 15 minutes) means cache purges may be delayed by that amount after content changes.

Note: Scheduled posts are handled specially. When a scheduled post is published via WP-Cron, the cache is purged synchronously within the same cron run, ensuring immediate cache invalidation without waiting for the next cron execution.

For detailed instructions on setting up a proper Linux-based WordPress cron, see: WordPress Cron Optimization.

WP-CLI

Purge

Les commandes Purge vous permettent de vider le cache.

  • wp varnish purge – Flush the entire site cache (equivalent to clicking « Empty Cache » in admin)
  • wp varnish purge --all – Explicitly flush the entire site cache
  • wp varnish purge <url> – Flush cache for a specific URL and all content below it (wildcard)
  • wp varnish purge <url> --url-only – Flush cache for only the exact URL specified (no wildcard)
  • wp varnish purge --tag=<tag> – Flush cache by tag (requires Cache Tags mode to be enabled)

Examples:

  • wp varnish purge – Purge entire site
  • wp varnish purge --all – Same as above, more explicit
  • wp varnish purge https://example.com/hello-world/ – Purge this URL and everything below it
  • wp varnish purge https://example.com/hello-world/ --url-only – Purge only this exact URL
  • wp varnish purge https://example.com/wp-content/themes/ --wildcard – Purge all theme files
  • wp varnish purge --tag=p-123 – Purge all pages tagged with post ID 123
  • wp varnish purge --tag=pt-post – Purge all cached pages of post type « post »

Debug

Le débogage peut vous aider à comprendre pourquoi votre cache ne fonctionne pas aussi bien qu’il le pourrait. La valeur par défaut est pour votre page d’accueil, mais vous pouvez tester n’importe quelle URL sur votre domaine.

  • débogage de wp varnish [<url>]

Paramètres disponibles :

  • [--include-headers] — Inclure les en-têtes dans la sortie de vérification de débogage
  • [--include-grep] — Répertoires de thèmes et d’extensions actifs de Grep pour les problèmes courants

DevMode

Le mode développement vous permet de désactiver temporairement le cache.

  • wp varnish devmode [<activate|deactivate|toggle>] – Modifier l’état du mode de développement

Async purge queue (cron-mode)

When you define DISABLE_WP_CRON as true and run a real system cron for WordPress, Proxy Cache Purge can move heavy purge work into a small background queue that is processed by WP‑Cron.

You can inspect and manage that queue via WP‑CLI:

  • wp varnish queue status – show whether cron-mode is active, if a full purge is queued, counts of queued URLs/tags, and the last queue run time.
  • wp varnish queue process – process any items currently in the queue (useful to run after deploys or cache‑sensitive operations).
  • wp varnish queue clear – clear the queue without sending any PURGE requests.

These commands do not replace your normal WordPress cron (you still need a cron entry that calls wp cron event run --due-now or hits wp-cron.php), but they give you a simple operational handle when using cron‑mode.

Gratuitsur le plan Business
En procédant à l’installation, vous acceptez les Conditions d’utilisation de WordPress.com ainsi que les Conditions de l’extension tierce.
Testé jusqu’à version
WordPress 6.9
Cette extension est disponible en téléchargement pour votre site .