← Back to blog

OPcache for WordPress: What It Does and How to Enable It

November 11, 2026
OPcache for WordPress: What It Does and How to Enable It

OPcache is a PHP extension that keeps compiled PHP code in server memory, so WordPress does not have to read and compile its files again on every request. If your host runs a modern PHP version, it is probably already on. Check it in Site Health, confirm it is enabled, and adjust a few memory settings only if the cache fills up. This guide shows how to do each step and where OPcache stops helping.

inSave Hosting
Give WordPress PHP a Faster Foundation
InSave Hosting offers WordPress hosting with LiteSpeed, LSCache, and PHP 8 to support performance-focused WordPress sites.
Explore hosting options

TL;DR

  • OPcache stores compiled PHP bytecode in shared memory. It does not store pages, images or database results.
  • It helps every PHP request, including the admin dashboard and logged-in users, where page caching often does not apply.
  • Check status under Tools, Site Health, Info in WordPress. On shared hosting, enable it in your control panel. On a VPS, enable it in php.ini.
  • Leave opcache.validate_timestamps on for most WordPress sites, because plugins and themes change files in place.
  • Pair OPcache with page caching and an object cache. They solve different problems.

Table of Contents

What OPcache does for WordPress

Every time someone requests a WordPress page that is not served from a page cache, PHP has to find the right files, read them, parse them and turn them into instructions the server can run. WordPress core, your theme and every active plugin go through that process. Without an opcode cache, it repeats on every single request.

An opcode cache breaks that loop. According to the WordPress Hosting Handbook, OPcache is bundled with PHP 5.5.0 and later and stores precompiled script bytecode in memory, so PHP files can be fetched from memory instead of being loaded and parsed each time. The first request compiles a file. Later requests reuse the result.

OPcache compiles PHP once and reuses bytecode

The history explains why it is so common now. The WordPress Codex notes that when PHP 5.5 arrived, Zend open-sourced its opcode caching code and contributed it to the PHP project, which is how it became part of standard PHP installations. Today, nearly every managed host ships it. The question is rarely "should I install it" and more often "is it switched on, and is it sized properly."

Who benefits most

The same Handbook page says opcode caching is especially useful for dynamic content and authenticated traffic, where full page caching is less effective. That covers a lot of real sites:

  • WooCommerce stores, where cart and checkout pages cannot be served as static HTML
  • Membership and learning sites with logged-in users
  • Sites with busy admin areas, where editors and authors spend all day in the dashboard
  • Sites with many plugins, because more code means more compiling to skip

A small brochure site with a handful of plugins and a page cache in front of it may see only a modest difference. That is normal. OPcache is a baseline layer, and its payoff grows with the amount of PHP your site runs.

What OPcache does not cache

This is where most confusion starts. OPcache works at the code level, not the content level. It stores compiled PHP, not the HTML that PHP produces and not the data WordPress pulls from the database.

That means WordPress still runs on every uncached request. It simply starts with less overhead. If a slow database query or a heavy plugin is your real bottleneck, OPcache will not fix it.

Here is how the three common caching layers compare:

LayerWhat it storesWho it helpsTypical tool
OPcacheCompiled PHP bytecodeEvery PHP request, including admin and logged-in usersPHP extension, set at server level
Object cacheReusable data and query results kept between requestsDynamic pages, WooCommerce, adminRedis or Memcached
Page cacheFinished HTML pagesAnonymous visitors on public pagesServer-level cache or a plugin

They are complementary. A single request can hit the page cache, miss it, run PHP from OPcache and pull data from an object cache, all in one pass. If you want to think through the whole stack, this overview of caching plugins for Elementor presents a layered approach to diagnosing PHP execution, repeated database work and page generation.

For the object cache layer on our side, see our guides on enabling an object cache in WordPress and reaching a high hit ratio with Redis. For the page cache layer, start with LiteSpeed Cache settings that are safe to use.

How to check whether OPcache is enabled

You do not need to touch the server to find out. WordPress reports it for you.

  1. Log in to your dashboard.
  2. Go to Tools, then Site Health.
  3. Open the Info tab and expand the server or PHP section.
  4. Look for the opcode cache entry.

Per the WordPress core change that added this test, Site Health shows whether the opcode cache is enabled and, where available, its memory usage, interned strings usage, hit rate and whether the cache is full. If the status function returns false, WordPress reports "Disabled by configuration." If the function is not available at all, it reports "Disabled" with a "not available" note in the debug field.

Those two messages point to different fixes:

  • Disabled by configuration: the extension is present, but a setting turned it off. Look at opcache.enable in your PHP configuration.
  • Not available: the extension is not loaded for the PHP version your site uses. Enable it in your control panel or php.ini.

If you see a message about this in a developer tool such as Query Monitor on a local copy of your site, the same logic applies. Your local environment has its own PHP configuration, separate from your live host.

Reading the numbers

Once OPcache is on, three figures tell you whether it is healthy:

  • Hit rate: the share of requests served from the cache. On a stable site, you want this high.
  • Memory usage: how much of the allocated shared memory is in use.
  • Full or not: a full cache cannot store new scripts, so some files get compiled again and again.

If the cache reports as full, or the hit rate is poor, move on to the settings below.

How to enable OPcache

The right method depends on who controls PHP on your server.

On cPanel shared hosting

Most shared hosts expose PHP settings in the control panel. In cPanel, open MultiPHP Manager or Select PHP Version, choose your PHP version, open the Extensions list, tick opcache and save. Interface labels vary a little between hosts, but the idea is the same: the extension is enabled per PHP version.

If the box is already ticked, you are done. On many plans it is on by default, so check Site Health before changing anything.

On a VPS or dedicated server

When you manage the server, you edit PHP's configuration yourself.

  1. Find the configuration file PHP loads: run php --ini and look for the loaded configuration line. Note that the command line and PHP-FPM can use different files, so confirm the one your web server uses.
  2. Add or uncomment zend_extension=opcache (on some systems opcache.so).
  3. Set opcache.enable=1.
  4. Restart PHP-FPM or Apache so the change takes effect.

The PHP manual explains that opcache.enable turns the opcode cache on, and that when it is off, code is neither optimized nor cached. It also notes you cannot switch it on at runtime with ini_set: it can only be disabled that way, and trying to enable it inside a script produces a warning. So a snippet in functions.php will not do the job. The setting belongs in server configuration.

When you have no php.ini access

Some hosts let you place a .user.ini file in your WordPress root to adjust PHP settings. That file can change settings for extensions that are already loaded, but it cannot load an extension. If Site Health says OPcache is unavailable, ask your host to enable it at the server level.

Settings that matter for WordPress

The defaults work for many small sites. Larger sites with lots of plugins can outgrow them. The Hosting Handbook recommends reviewing five settings: opcache.memory_consumption, opcache.interned_strings_buffer, opcache.max_accelerated_files, opcache.validate_timestamps and opcache.revalidate_freq.

The Docket Cache documentation describes how the first three work together. OPcache reserves one shared memory segment when PHP starts, and that segment does not grow afterward. Three limits are fixed at start-up:

SettingWhat it controlsDefault
opcache.memory_consumptionTotal size of the shared memory, in MB128 MB
opcache.interned_strings_bufferMemory for shared copies of identical strings, in MB8 MB
opcache.max_accelerated_filesNumber of keys in the script hash table, so roughly how many files can be cached10000

The PHP manual adds that the minimum permitted value for opcache.memory_consumption is 8 MB, and a smaller value is raised to that floor.

When to raise the limits

Because the memory segment is fixed, a site that needs more than it was given will fill the cache. Signs to look for in Site Health or a status page:

  • The cache reports as full.
  • Memory usage sits near the allocated amount.
  • The hit rate falls even though traffic is steady.

A site with a large plugin stack, several themes installed, or many sites sharing one PHP pool is the usual candidate. Raise opcache.memory_consumption first, then opcache.max_accelerated_files if you have a very large number of PHP files. Change one value at a time, restart PHP and look at the numbers again.

Timestamp validation: the setting to leave alone

opcache.validate_timestamps decides whether OPcache checks if a file changed before using its cached copy. Turning it off can shave a little overhead, but it comes with a catch. The Docket Cache documentation points out that WordPress is not deployed as immutable releases: plugins, themes and core update in place from the dashboard, and files are often edited over SFTP. For most sites it recommends leaving timestamp validation on (opcache.validate_timestamps=1). Turning it off means you are responsible for resetting OPcache whenever any PHP file changes outside the WordPress updater.

In plain terms: if you disable validation and then update a plugin by uploading files, the server can keep running the old code until the cache is reset. That is the most common reason people think "my changes are not showing up." Leave validation on unless you run a controlled deployment process that resets the cache every time.

Clearing OPcache

With timestamp validation on, you rarely need to clear anything. PHP notices changed files on its own, at the interval set by opcache.revalidate_freq.

If you have turned validation off, or you are troubleshooting odd behavior after a deployment, reset the cache in one of these ways:

  • Restart PHP-FPM or the web server, which empties the cache.
  • Use your control panel's PHP restart or cache option if it has one.
  • Ask your host to reset it if you cannot reach the server.

A WordPress plugin that adds a reset button can help on hosts where you cannot restart services. It only works if the OPcache functions are not blocked on your server.

OPcache troubleshooting checklist

If Site Health flags OPcache or performance has not improved, work through this list in order:

  1. Confirm the PHP version. OPcache is enabled per PHP version in many control panels. If you switched versions, check again.
  2. Read the exact Site Health message. "Disabled by configuration" and "not available" need different fixes.
  3. Check for a full cache. Raise memory and file limits if needed.
  4. Look at stale code. If changes do not appear, check whether timestamp validation is off.
  5. Look elsewhere for the bottleneck. If OPcache is healthy and the site is still slow, the cause is usually somewhere else: uncached pages, slow queries, heavy plugins or an overloaded plan. Our guide to fixing a slow WordPress site covers the quick wins, and these five checks for shared hosting cover the hosting side.

If the dashboard in particular feels sluggish, OPcache is one of the layers that helps most there, since page caching does not apply to the admin. Our list of priority fixes for a slow WordPress admin goes through the rest.

A sensible order of operations

For a typical site, this sequence gets the most for the least effort:

  1. Run a current, supported PHP version.
  2. Confirm OPcache is on in Site Health.
  3. Add a page cache for anonymous visitors. If you are on LiteSpeed, our explainer on what LSCache is shows how it works.
  4. Add an object cache if your site is dynamic or database-heavy.
  5. Revisit OPcache memory only if the numbers show the cache is full.

Notice that OPcache comes first and needs the least attention. That is the point of a baseline layer: set it once, check it occasionally and let it work.

Perspective

Most of the OPcache problems we see are not about exotic tuning. They come from one of two things: the extension was never switched on for the PHP version the site actually runs, or someone turned off timestamp validation to chase a benchmark and then wondered why plugin updates did not seem to take.

Our approach is to make the baseline right before the site owner has to think about it. Our sites are managed by experienced SRE and DevOps engineers in the EU and US, and our platform is built around LiteSpeed, LSCache, MariaDB, HTTP/2 and PHP 8, with a free CDN. OPcache is one layer in that stack, and we configure it to work alongside page and object caching instead of in place of them.

If you run WordPress, we think the right goal is a stack where each layer does one job well: OPcache for PHP execution, an object cache for repeated data, a page cache for anonymous visitors. And when you move to us, we handle the migration for free, so you do not have to rebuild that stack by hand.

Ihor

Hosting that sets this up for you

If you would rather not edit PHP settings at all, our WordPress hosting plans are built for exactly this. They run on LiteSpeed with LSCache, include free SSL, daily backups and free migration, and come with a 30-day money-back guarantee. If you outgrow shared resources and want to control PHP configuration yourself, our VPS hosting gives you the server-level access described above.

inSave Hosting

Not sure which plan fits? Start with our shared hosting for smaller sites, or see everything we offer on insave.hosting.

FAQ

Is OPcache the same as WordPress page caching?

No. OPcache stores compiled PHP code, while a page cache stores finished HTML pages. OPcache helps every request PHP handles, including the admin, and a page cache mainly helps anonymous visitors. Most fast sites use both.

Do I need a plugin to use OPcache?

No. OPcache is a PHP extension configured on the server, not a WordPress plugin. A plugin can show status or add a reset button, but the extension itself must be enabled through your control panel or PHP configuration.

Will OPcache make my WordPress site faster?

It reduces the work PHP does on each request, so dynamic and logged-in traffic benefit most. The Hosting Handbook notes it lets a server handle many more requests than it otherwise could. Gains are smaller on tiny sites that already serve cached pages.

Why does Site Health say the opcode cache is disabled?

Either the extension is not loaded for your PHP version, or a setting such as opcache.enable turned it off. Check the exact message in Site Health, then enable it in your control panel or php.ini, or ask your host to do it.

Should I turn off timestamp validation for more speed?

For most WordPress sites, no. Plugins, themes and core update in place, so disabling validation means you must reset OPcache after every file change outside the WordPress updater. Leave it on unless you run controlled deployments.

Sources