WP Cron Flush Acorn Caches
Flush Acorn caches every 3 hours
Install
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.zipA 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
- Upload
wp-cron-flush-acorn-caches.phpto your/wp-content/plugins/directory. - 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:
- 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. - WP-CLI API (
WP_CLI::runcommand) — used when the cron event is triggered viawp cron event run. 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