Skip to content

feat(purge): purge page caches on deploy by a per-site mode - #13

Merged
oxyc merged 1 commit into
masterfrom
feat/deploy-purge-mode
Nov 16, 2026
Merged

oxyc merged 1 commit into
masterfrom
feat/deploy-purge-mode

Conversation

@oxyc

@oxyc oxyc commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Every deploy empties the page caches, often twice. cache:clear:wp:objectcache runs wp cache flush, which kinsta-mu-plugins hooks to purge the whole Kinsta page cache, and most sites also run cache:clear:kinsta. solarplexius and mutti each worked around this in their own deploy.php (https://github.com/generoi/solarplexius/pull/259, https://github.com/generoi/mutti/pull/242). This moves that here and makes the purge a setting.

purge.php (opt-in, so sites that don't import it are unchanged) adds cache:purge, which runs the site's purge_tasks as purge says:

purge Does
soft (default) Purge, softly where the CDN can (sage-cachetags with a soft invalidator). Kinsta has no soft purge, so it is always emptied.
hard The same, with wp cachetags flush --hard.
auto hard when the built assets changed, otherwise nothing.
none Nothing.

A site sets its default with set('purge', 'auto'); a deploy overrides it with -o purge=hard, which the deploy workflow's new purge input passes (generoi/github-actions#85).

  • cache:check_assets runs before deploy:symlink and compares a checksum of the files under assets_dirs (default {{theme_dir}}/build) in the live and new release. It hashes the whole directory, so Mix's public/, wp-scripts' build/ and dist/ all work. If a directory isn't in the release, it warns and purges, so a wrong path can't silently stop purges. Rollbacks don't run it, so under auto they always purge. It also rejects an invalid purge before the release goes live.
  • cache:clear:wp:objectcache:only flushes the object cache with wp eval "wp_cache_flush();", which Kinsta doesn't hook.
  • cache:clear:cachetags adds --hard for a hard purge (feat: flush --hard purges with soft invalidators too sage-cachetags#72).
  • Purge tasks are best-effort: one that fails warns, and the rest still run.

cache:clear:wp:objectcache itself is unchanged, because Panini relies on its implicit Kinsta purge and has no cache:clear:kinsta.

Tested with Deployer 7 on a local host:

  • auto with changed assets runs hard;
  • -o purge=soft overrides a site's auto;
  • an invalid mode fails;
  • a failing purge task warns and the rest still run.

The checksum pipeline was run in a Linux container for these cases:

  • identical builds → equal;
  • one file changed → differ;
  • a missing current → differ, exit 0.

Not yet run in a real deploy; solarplexius and mutti are the pilots.

🤖 Generated with Claude Code

purge.php adds cache:purge, run as purge says: soft (default), hard,
auto (hard when the built assets changed, otherwise nothing) or none.
A site sets its own default; a deploy overrides it with -o purge=hard.

It also adds cache:clear:wp:objectcache:only, since wp cache flush
makes kinsta-mu-plugins purge the whole Kinsta page cache, and
cache:clear:cachetags, which passes --hard for a hard purge. The
recipe is opt-in, so sites that don't import it are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant