3 Page caches
Robin edited this page 2026-11-23 00:48:15 +01:00

Page caches

When a translation changes (a new translation, a correction, a block for one language, a changed slug), its page is purged in every language, so that visitors see it at once:

  • WordPress's own object cache;
  • W3 Total Cache, WP Super Cache, WP Rocket and LiteSpeed Cache, when they are active.

A change to the whole site (a menu, a template part, the site's title) purges the whole cache. Purges are gathered and sent once at the end of the request, and logged.

Nothing is purged while the translations are not shown on the site (preparation, or another translation plugin still serving it): no page shows them yet. Turning them on or off purges the whole cache once. A translation finished with nothing new purges nothing.

Settings → Advanced → Page caches lists the cache plugins found.

A cache of the server

A cache of the server itself (nginx fastcgi_cache or proxy_cache, Varnish, a CDN) is not reached by WordPress plugins. Keep its duration short (a few minutes) for HTML pages, or purge it after a correction.

Or purge it from code, with the lrob_ai_translator_purge action:

add_action( 'lrob_ai_translator_purge', function ( array $urls, bool $all ) {
	if ( $all ) {
		my_cdn_purge_everything();
		return;
	}
	foreach ( $urls as $url ) {
		my_cdn_purge_url( $url ); // https://example.com/about/, https://example.com/en/about/…
	}
}, 10, 2 );

Translated pages behind a page cache

A translated page is a page like any other for a page cache: each language has its own address, so each is cached on its own. Behind a page cache, serving a translation costs nothing more than serving the original.