How to Flush and Monitor PHP OPcache in WordPress Without Downtime
Image
PHP OPcache is a core PHP extension that improves WordPress performance by storing precompiled PHP bytecode in shared memory, eliminating repeated parsing and compilation on every request. On high-traffic or plugin-heavy sites, this reduces CPU usage and stabilizes response times.
However, OPcache operates at the server layer, not inside WordPress. Many teams expect a plugin to control OPcache the same way it controls page or object caching, but OPcache doesn’t work like that. What plugins can influence, what the server ultimately controls and where hosting platforms like Pantheon draw that boundary are the key distinctions you need to understand – so let’s break it down.
What WordPress OPcache plugins actually do
WordPress OPcache plugins don’t make WordPress faster by adding a new cache. Instead, they help you see, control and safely work with a performance feature that already exists at the PHP level.
At a high level, PHP OPcache speeds up WordPress by keeping compiled PHP code in memory so it doesn’t have to be reprocessed on every request. This happens outside WordPress itself, which is why OPcache can feel confusing. It’s always running in the background, but WordPress doesn’t natively expose what it’s doing. That’s why people turn to WordPress OPcache plugins.
Most WordPress OPcache plugins only help with:
- Provide visibility: Show whether OPcache is enabled, how much memory it’s using and whether it’s actually being hit. Without a plugin, OPcache is effectively invisible.
- Handle safe cache clearing: When WordPress core, plugins or themes are updated, cached PHP code can become outdated. OPcache plugins help invalidate cached code at the right moment so updates don’t cause errors.
- Support workflows: Some plugins integrate with WP-CLI or add admin tools so developers can flush or warm OPcache during deploys instead of reacting to issues after the fact. However, we don’t recommend this at all if you’re a Pantheon user.
What WordPress OPcache plugins don’t do is enable OPcache, change low-level PHP settings or replace page and object caching. They also don’t make poorly written code fast – they simply ensure PHP executes efficiently.
Does your hosting setup need a WordPress OPcache plugin?
Usually, no, your hosting setup won’t need a WordPress OPcache plugin. In most modern WordPress hosting environments, OPcache is already enabled and working at the server level without any plugin required.
OPcache is a server-level PHP feature, not something WordPress controls directly. On managed platforms like Pantheon, OPcache is part of the underlying runtime and is not customer-configurable. In live environments, code isn’t written directly and OPcache is automatically cleared as part of the deploy process. That means there’s no expectation or need for site owners to manually flush OPcache during normal updates.
Verify OPcache is enabled on your server
As we said before, in most modern WordPress hosting, especially managed platforms, OPcache is already enabled by default. Still, verifying it can help you understand how your environment is working.
One option to check whether OPcache is enabled on your server is by using phpinfo():
- Create a file called phpinfo.php in your WordPress root.
- Add this code:
<?php phpinfo(); ?>
- Visit https://your-site.com/phpinfo.php.
- Search the page for OPcache. If OPcache is enabled, you’ll see a dedicated OPcache section and a setting called “opcache.enable” set to On.
- Delete the file immediately after checking because it exposes server details.
If you’d rather not create files, WordPress’s built-in Site Health tool can sometimes surface OPcache status under Tools > Site Health > Info > Server, depending on your host.
And, if you want to use a plugin for this and for ongoing visibility, OPcache Manager or WP OPcache are good options. Though keep in mind that plugins don’t enable OPcache.
Pick the right WordPress OPcache plugin for your workflow
Let’s reiterate that WordPress OPcache plugins don’t change how OPcache behaves internally. They only provide different ways to observe it, coordinate it with updates or interact with it during development.
Which plugin – if any at all – makes sense depends on how your site is hosted and how code changes are introduced:
- Visibility into OPcache health: Monitoring-focused plugins like OPcache Manager surface metrics that are otherwise hidden, including hit rate, memory usage and cached file counts. This is most valuable when troubleshooting performance issues or validating that OPcache has enough memory allocated for a large plugin stack or WooCommerce site.
- Manual control in development environments: Lightweight tools such as WP OPcache add a simple way to manually clear cached PHP during active development or staging work. These plugins are best suited for non-production environments where code changes happen frequently and immediate feedback matters.
- Plugins for automatic cache coordination after updates: Plugins such as OPcache Reset are designed to clear cached PHP code immediately after WordPress core, theme or plugin updates run. However, we don’t recommend this at all!
- Specialized object caching on shared hosting: Some plugins, such as Docket Cache, use OPcache indirectly by storing object cache data as PHP files. This approach can help on shared hosting where Redis or Memcached aren’t available, but it serves a different purpose than OPcache management.
⚠️ As a general rule, we do not recommend managing OPcache yourself from inside WordPress and that includes relying on plugins to flush or control it.
On platforms like Pantheon, OPcache is already managed as part of the deployment process and is cleared automatically when code is deployed. It is tightly integrated into the platform’s deployment workflow and is automatically cleared when code is deployed. Customers cannot (and do not need to) change OPcache settings at the server level and manual cache flushing is intentionally not part of the normal workflow.
Because of that, installing WordPress OPcache plugins on Pantheon can be misleading at best and harmful at worst if they encourage behaviors that don’t align with how the platform works.
Clear or flush OPcache safely during updates and deploys
OPcache makes WordPress fast by reusing compiled PHP code, but that same behavior means it must be handled carefully when code changes. If WordPress core, a plugin or a theme is updated, OPcache may continue serving an older compiled version of the code unless it’s told that something changed. When that happens, WordPress can briefly run a mix of old and new code, which is where fatal errors and strange post-update bugs come from.
How you deal with this depends entirely on your hosting setup.
On managed WordPress platforms like Pantheon, customers are not expected to manually flush OPcache at all. Code is deployed through a controlled pipeline, PHP files aren’t writable on Live and OPcache is automatically cleared as part of the deploy process. Installing plugins or workflows that attempt to bypass that deploy → cache-clear sequence can actually cause issues rather than prevent them.
On self-managed servers or shared hosting, things are different. If OPcache is configured for performance and doesn’t automatically check for file changes, then clearing OPcache after updates becomes essential. The safest approach for most WordPress sites in these environments is automation. Plugins such as OPcache Reset clear OPcache immediately after WordPress core, plugin or theme updates, ensuring new code is executed consistently without requiring server access.
Be especially cautious with code that calls opcache_reset(). This function clears the entire OPcache memory pool immediately, forcing PHP to recompile all files and potentially causing CPU spikes under load. It should never run during normal site activity or common admin actions and is best reserved for controlled deployment workflows at the server level.
If you do have server access, reloading PHP-FPM as part of your deployment process is the most reliable method. A graceful reload clears OPcache while allowing active requests to finish, making it suitable for production use. This approach is commonly wired into CI/CD pipelines.
What’s just as important is knowing when not to clear OPcache. Publishing content, editing pages, changing settings or updating database-driven content does not require OPcache clearing, because OPcache only affects PHP code, not HTML output or stored data. Clearing it unnecessarily can hurt performance, especially on high-traffic sites, by forcing PHP to recompile everything at once.
So, the safest approach is to let your hosting platform handle OPcache automatically when possible and only introduce explicit clearing when your workflow truly requires it.
Monitor OPcache health with the right metrics
OPcache problems rarely present as clear errors. They may show up indirectly through slower response times, elevated CPU usage or brief performance drops after deployments or updates. For those of you not using managed WordPress hosting, monitoring can help you identify these issues early and confirm that OPcache is correctly sized and behaving as expected.
Here’s what to look out for:
- Hit rate: This tells you how often PHP is able to reuse cached, precompiled code instead of recompiling files from disk. On a healthy WordPress site, hit rate should stay at or above 98%, with well-tuned setups sitting closer to 99-100%. If it drops consistently, OPcache is doing extra work, usually because it doesn’t have enough memory or can’t index all PHP files.
- Memory usage: OPcache needs enough space to hold your entire active codebase – core, themes and plugins. If free memory gets too low, the cache starts evicting files or restarting, which temporarily wipes out performance gains. That’s why unexpected slowdowns often line up with memory exhaustion rather than traffic spikes.
- Capacity limits: OPcache tracks how many PHP files it can cache and if that limit is too low, files simply stop being cached even if memory is available. This is common on WordPress sites with WooCommerce or large plugin stacks and shows up as declining hit rates without obvious errors.
- Restart counters: Any unexpected OPcache restarts outside deploy windows usually mean configuration issues, not traffic problems.
On most managed platforms, including Pantheon, OPcache is already monitored and coordinated with deployments at the platform level, so users never have to keep an eye out for these metrics directly.
Don’t worry about WordPress OPcache management with Pantheon
By now, you already know that OPcache lives at the PHP and hosting layer, not inside WordPress. And unless you absolutely need to handle OPcache yourself, it’s best to leave it to your managed WordPress hosting.
On Pantheon, you don’t have to do a single thing when it comes to the OPcache in WordPress. The platform safely and automatically clears OPcache at the right moment, without exposing OPcache settings, buttons or reset logic to WordPress.
This removes the need for WordPress OPcache plugins entirely on Pantheon. There’s no guessing when to flush, no risk of stale bytecode after updates and no plugins trying to override PHP behavior mid-request. OPcache is treated as part of the runtime, not a WordPress feature to manage.
Beyond OPcache, Pantheon provides:
- A container-based infrastructure running on Google Cloud. Each site runs in isolated Linux containers with an optimized PHP and NGINX stack, which gives you consistent performance and removes the “noisy neighbor” problems common on shared hosting.
- Dev, Test, Live environments that make it easy to move changes forward with confidence.
- Multidev, which lets you spin up isolated environments for feature branches, QA or content previews without cloning sites manually.
- Free, managed HTTPS.
- Performance optimizations, caching, a global content delivery network (CDN) and enterprise-grade security.
The end result is a WordPress hosting environment that delivers optimal performance.
Want hosting that handles the heavy lifting for you? Try Pantheon today and unlock a faster, more reliable WordPress workflow.