DEV Community

Cover image for OPcache for WordPress: The PHP Cache Your Site Should Not Run Without
Christian Ahrweiler
Christian Ahrweiler

Posted on

OPcache for WordPress: The PHP Cache Your Site Should Not Run Without

When people talk about WordPress performance, they often think about page cache, image optimization, CDN, or object cache.

All of that matters. But one of the most important performance layers sits below WordPress itself: OPcache.

OPcache is a PHP engine cache. It stores already compiled PHP code in memory, so PHP does not have to read, parse, and compile the same files again on every request.

For WordPress, that is a big deal.

A normal WordPress page load touches many PHP files: WordPress core, plugins, themes, autoloaders, libraries, and configuration files. Without OPcache, PHP has to process this code again and again. With OPcache enabled, the compiled version can be reused directly from memory.

The result is less CPU work, faster response times, and better stability under load.

OPcache is a basic WordPress hosting requirement
OPcache does not replace a page cache. It also does not replace Redis, Memcached, APCu, or a CDN.

It works at a lower level.

Even when a page is not cached, WordPress still has to run PHP. OPcache makes that PHP execution more efficient. That is why OPcache should be considered a basic requirement for serious WordPress hosting.

If OPcache is disabled, WordPress is forced to do unnecessary work on every request.

The main OPcache settings

The most important setting is:

opcache.memory_consumption

This defines how much memory OPcache may use for cached PHP scripts. If the value is too small, OPcache fills up quickly and cannot keep all important files cached. Small WordPress sites may be fine with 128 MB, while larger plugin-heavy sites often benefit from 256 MB or more.

Another important setting is:

opcache.interned_strings_buffer

This stores repeated strings used by PHP, such as class names, function names, file paths, array keys, and configuration values. WordPress and plugins use many of these strings. Common values are 8 MB, 16 MB, or 32 MB.

The third key setting is:

opcache.max_accelerated_files

This controls how many PHP files OPcache can store. WordPress installations with many plugins can easily contain thousands of PHP files. If this limit is too low, not all files can be cached, even if memory is still available.

Typical values are 10,000 or higher. Larger sites may need 20,000 or more.

Enabled is not enough

A common mistake is to only check whether OPcache is enabled.
That is not enough.

OPcache can be active but still badly configured. It may have too little memory, too small a string buffer, or too low a file limit. In that case, WordPress runs, but OPcache cannot help as much as it should.

The important part is not only whether OPcache is enabled, but whether it has enough room to work properly. A useful check should show how much OPcache memory is available, how much is already used, how much free memory is left, how many PHP files are cached, and whether the configured file limit is large enough for the site. It should also reveal warning signs such as wasted memory or cache restarts, because those can indicate that OPcache is too small or not tuned well for the WordPress installation.

How to check OPcache in WordPress

Many hosting panels only show that OPcache is "available". That does not tell you whether it is configured well.

This is where atec Cache Info by atec Plugins helps.

atec Cache Info shows system-level cache status and statistics directly inside WordPress. It detects OPcache, PHP JIT, object cache type and health, APCu, Redis, Memcached, and SQLite cache support. It is read-only and does not modify your server configuration.

For OPcache, it helps you see the actual runtime situation instead of guessing. You can check whether OPcache is active, how it is configured, and whether the limits are suitable for your WordPress installation.

The bottom line

Good WordPress performance starts with the server foundation.
Before optimizing themes, removing plugins, or adding more frontend tricks, it makes sense to check whether PHP itself is running efficiently.

OPcache is one of the simplest and most effective performance features for WordPress. But it only helps fully when it is enabled, large enough, and correctly configured.

And if you want to check that directly inside WordPress, use atec Cache Info.

Top comments (0)