Query the right OPcache, not the CLI one
php -i | grep opcache or php -r over SSH and trusting the result. The PHP CLI has its own OPcache instance, separate from the PHP-FPM or LiteSpeed LSAPI workers that serve the website. On most setups it is not even enabled, because opcache.enable_cli is off by default. The CLI can also load different ini files from the web handler. You need to call opcache_get_status() from inside the web SAPI (the PHP handler that serves web requests), which means a small PHP file requested over HTTP. The same approach comes up in this r/ProWordPress thread about slow admin and OPcache.
The script below prints only the counters that matter and the effective settings for that handler. It passes false to opcache_get_status() so that it skips the per-script list, which can be very long and exposes file paths.
PHP
<?php
// opcache-check.php: temporary diagnostic, delete it when you are done
header('Content-Type: text/plain');
if (!function_exists('opcache_get_status')) { exit('OPcache extension not loaded' . PHP_EOL); }
$s = opcache_get_status(false);
if ($s === false) { exit('OPcache disabled or API restricted for this handler' . PHP_EOL); }
m =s['memory_usage'];
st =s['opcache_statistics'];
is =s['interned_strings_usage'];
$mb = 1048576;
printf('memory used=%.1fMB free=%.1fMB wasted=%.1fMB wasted_pct=%.2f' . PHP_EOL, m['used_memory'] /mb, m['free_memory'] /mb, m['wasted_memory'] /mb, $m['current_wasted_percentage']);
printf('interned_strings used=%.1fMB free=%.1fMB' . PHP_EOL, is['used_memory'] /mb, is['free_memory'] /mb);
printf('scripts=%d keys=%d max_keys=%d' . PHP_EOL, st['num_cached_scripts'],st['num_cached_keys'], $st['max_cached_keys']);
printf('hit_rate=%.2f hits=%d misses=%d' . PHP_EOL, st['opcache_hit_rate'],st['hits'], $st['misses']);
printf('oom_restarts=%d hash_restarts=%d manual_restarts=%d' . PHP_EOL, st['oom_restarts'],st['hash_restarts'], $st['manual_restarts']);
printf('start=%s last_restart=%s cache_full=%s' . PHP_EOL, date('c', st['start_time']),st['last_restart_time'] ? date('c', st['last_restart_time']) : 'never', var_export(s['cache_full'], true));
foreach (['opcache.memory_consumption', 'opcache.max_accelerated_files', 'opcache.max_wasted_percentage', 'opcache.interned_strings_buffer', 'opcache.validate_timestamps', 'opcache.revalidate_freq'] as $k) {
echo k, '=', ini_get(k), PHP_EOL;
}opcache.restrict_api and disable_functions. On shared hosting you may not be allowed to change either, so ask the host.
If you run several PHP versions or pools, each one has its own cache. Put the file under the site you are investigating so that the request reaches the correct handler.
Capture a baseline, deploy, capture again
BASH
# Before the deploy (replace the URL and paths with your own)
curl -s 'https://example.com/opcache-check-RANDOM.php' > /tmp/opcache-before-$(date +%s).txt
# Count PHP files the site can load (include vendor and plugin dirs)
find /home/USER/public_html -type f -name '*.php' | wc -l
# Deploy, browse a few pages, then capture again and compare
curl -s 'https://example.com/opcache-check-RANDOM.php' > /tmp/opcache-after-$(date +%s).txt
diff /tmp/opcache-before-*.txt /tmp/opcache-after-*.txt
# When finished, remove the diagnostic file
rm /home/USER/public_html/opcache-check-RANDOM.phpdiff line assumes one before file and one after file in /tmp. If you run several rounds, name the files by hand. Requesting the check file itself counts as a hit or a miss, which does not matter at this scale.
What each counter is telling you
oom_restarts counts restarts caused by running out of memory, hash_restarts counts restarts caused by a full key table, and manual_restarts counts explicit resets. Compare last_restart_time with your deploy time. If they match, you have found the trigger.
To understand why deploys trigger these restarts, you need to know about wasted memory. With opcache.validate_timestamps=1, PHP checks whether a cached file changed on disk. It checks at most once every opcache.revalidate_freq seconds, not on every request. When a file changed, PHP compiles the new version and marks the old copy as wasted. OPcache does not compact memory, so the wasted space is only reclaimed by a full restart. A deploy that touches thousands of files can therefore consume a large part of the cache in one go.
When memory runs out, OPcache compares the wasted percentage with opcache.max_wasted_percentage. If waste is above that threshold, OPcache schedules a restart and oom_restarts goes up. If waste is below the threshold, OPcache does not restart. It sets cache_full to true and stops caching new scripts, so any script that did not make it into the cache is compiled on every request. A full cache is the harder case to notice: nothing resets, yet some pages stay slow. In both cases the fix is more memory.
Next, look at the keys. The Server Fault question on OPcache resetting automatically suggests checking whether num_cached_scripts sits close to the max_accelerated_files limit. Use max_cached_keys from the output as the real ceiling. PHP rounds the configured value up to the next number in an internal list of primes, so max_cached_keys is often a bit higher than what you set. num_cached_keys can also be larger than num_cached_scripts, because a single file can be stored under more than one key when it is included by different paths. Compare both numbers with your find count. A WordPress site with many plugins, or a Laravel or Symfony app with a large vendor directory, can have more files than the default allows.
Treat opcache_hit_rate with care. It is a total since start_time, so a cache that has run for weeks will show a high rate even if the last deploy hurt badly. Look at how misses changes between two readings taken a few minutes apart. If misses keep rising quickly long after traffic has touched the usual pages, scripts are not staying in the cache.
Finally, manual_restarts. A rising count means something called opcache_reset(). That could be a deploy script, a cache or optimization plugin, or a tool such as a control panel action. Resetting on purpose after a deploy is sometimes the right call. A plugin that resets on every settings save is not. Also check whether start_time moved without any restart counter changing. That usually means the PHP service was restarted or reloaded, which rebuilds the cache from scratch. Whether a reload clears the cache depends on the handler and how it was configured.
Sizing memory_consumption and max_accelerated_files
opcache.memory_consumption, and max_cached_keys should sit comfortably above your PHP file count. Leave room for plugin installs and dependency updates. If interned_strings_usage shows little free memory, raise opcache.interned_strings_buffer as well. That buffer stores repeated strings such as class and function names, and it is part of the total shared memory.
INI
; Illustrative values only. Derive yours from the before/after readings.
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.interned_strings_buffer=16ini_set() will not change them, and neither will a php_value line in .htaccess. Where they live depends on the setup: a conf.d OPcache ini file on Debian or Ubuntu packages, a per-version php.ini, or the PHP ini editor in your control panel. Changes take effect only after a full restart of the PHP handler, and that restart empties the cache once. Plan it outside peak hours. Keep in mind that each PHP version or pool allocates its own cache, so the total RAM cost grows with every version or pool you run.
Raising opcache.max_wasted_percentage is not a real fix. It only lets waste build up longer before the restart, and the cache can still fill before that point.
Confirm the change actually landed
ini_get lines show your new values. If they still show the old ones, you edited an ini file that this handler does not load. This is common when the CLI and the web handler use different configurations, or when the panel manages its own copy of the file. Next, start_time should show the restart, and the restart counters should be back at zero, since they count from cache creation.
The real test is the next deploy. Capture a baseline, deploy, and capture again. You want oom_restarts and hash_restarts to stay at zero, cache_full to stay false, and free memory to remain after the wasted share grows. If WordPress admin pages are still slow while the cache is healthy, the cause lies elsewhere. Why WordPress Admin Is Slow Even When the Frontend Loads Fast covers other causes. Remember that a page cache can hide all of this for anonymous visitors, which is why OPcache problems often show up first for logged-in users. Is LSCache Actually Serving Your WordPress Pages? explains how to tell which requests reach PHP at all.
In practice, when a site gets slow only after releases, read opcache_get_status() through the web handler before you touch anything else. A restart counter that matches your deploy time, or cache_full set to true, points to memory or keys. Your file count and the before and after readings tell you how much to add. Then the next deploy confirms whether it was enough.