WP Manifestindependent plugin directory
manifest / performance / wp-cron-flush-acorn-caches

WP Cron Flush Acorn Caches

Flush Acorn caches every 3 hours

★ 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/rkalajian/wp-cron-flush-acorn-caches/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.

A lightweight WordPress plugin that automatically flushes Roots Acorn caches on a recurring schedule via WP-Cron. Particularly useful for Sage 10 themes on WPEngine, where manual cache clearing after deployments or content updates is error-prone.

What It Does

Every 3 hours the plugin runs two Acorn Artisan commands:

Command Effect
optimize:clear Clears bootstrapped config, route, and event caches
view:cache Recompiles all Blade view templates

Requirements

  • WordPress 5.5+
  • PHP 7.4+ (PHP 8.0+ recommended; required by Acorn 3+)
  • Roots Acorn 2+ (installed as part of a Sage 10 theme or standalone)
  • WP-Cron enabled (or a real cron job calling wp-cron.php)

Installation

  1. Upload wp-cron-flush-acorn-caches.php to your /wp-content/plugins/ directory.
  2. Activate the plugin through the Plugins screen in WordPress.

On activation the two cron events are scheduled immediately. On deactivation they are removed.

How Commands Are Executed

The plugin tries three execution methods in order, stopping at the first that succeeds:

  1. Acorn PHP API (\Roots\app()) — preferred; runs entirely in-process, no shell required. This is the method that works on WPEngine and other hosts that restrict shell functions.
  2. WP-CLI API (WP_CLI::runcommand) — used when the cron event is triggered via wp cron event run.
  3. shell_exec — last resort fallback for environments where the Acorn PHP API is unavailable. Logs output to the PHP error log.

WPEngine Notes

WPEngine disables shell_exec and similar functions. The plugin handles this automatically by preferring the Acorn PHP API (method 1), which requires no shell access and works out of the box.

Customising the Schedule

The default interval is every 3 hours. To change it, use the cron_schedules filter or replace the three_hours key in the plugin with your own custom interval.

License

MIT