fbpx

OPcache Reset for WordPress

This plugin clears OPcache after updating WordPress core, themes, and files.
Unlike other plugins, it is also compatible with WordPress updates made by Linux cron.

Requirements:

1. cachetool

The cachetool is a little CLI utility that is capable of talking to your PHP-FPM instance in order to clear PHP OPcache.

sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
sudo yum -y install cachetool

2. Set up opcache.validate_timestamps setting

The most efficient way to run PHP scripts of any kind in production: opcache.validate_timestamps set to Off.

In this way, any scripts are not checked for changes. This saves a lot of disk activity for PHP frameworks which have to parse dozens and dozens of scripts on every request.

Set this in your PHP-FPM configuration, or global PHP configuration and when you invoke PHP from cron:

opcache.validate_timestamps=0

Learn more.

3. WP-CLI

sudo yum -y install wp-cli

Install the plugin using WP-CLI:

wp plugin install opcache-reset --activate

That’s it. Zero configuration is required.