From 49bf47fd6f47e22604567e5d209ce6b1d183321e Mon Sep 17 00:00:00 2001 From: Kamran Abdul Aziz Date: Sun, 7 Jun 2026 00:48:22 +0530 Subject: [PATCH 1/3] Improve OPcache performance guidance --- performance.md | 16 ++++++++++++++++ server-environment.md | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/performance.md b/performance.md index 38030e2..b6803cf 100644 --- a/performance.md +++ b/performance.md @@ -77,6 +77,22 @@ The web server must read, compile, and run each PHP script. An opcode cache stor As with any cache, opcode caches can keep changes from taking effect until the cache expires or is purged. With opcode cache specifically, this means older versions of the compiled PHP code will be loaded. When updating plugins, themes, or WordPress core, the appropriate files should be purged from the cache to avoid continuing to load the older versions. +[OPcache](https://www.php.net/manual/en/book.opcache.php) is the opcode cache bundled with modern PHP versions. It improves PHP performance by storing precompiled script bytecode in shared memory, which reduces the need to load and parse the same PHP files on each request. + +For production WordPress environments, OPcache should generally be enabled for web requests and sized for the site or hosting platform. Important [OPcache runtime configuration](https://www.php.net/manual/en/opcache.configuration.php) settings to review include: + +- `opcache.memory_consumption`, which controls the shared memory available to OPcache. +- `opcache.max_accelerated_files`, which controls how many scripts can be cached. +- `opcache.validate_timestamps` and `opcache.revalidate_freq`, which control how OPcache checks whether cached PHP files have changed. + +If `opcache.validate_timestamps` is disabled, file changes will not be picked up automatically. In that configuration, OPcache must be reset or specific scripts must be invalidated during deployment, or the web server/PHP process must be restarted, so updates to WordPress core, plugins, and themes do not continue serving older compiled code. + +During active development, a shorter revalidation interval can reduce confusion when code changes do not appear immediately. In production, a longer interval or manual invalidation can reduce filesystem checks, but it should be paired with a reliable deployment or update process that clears OPcache when files change. + +Hosts should also monitor OPcache usage over time. If the cache runs out of memory, reaches the configured script limit, or restarts frequently because of wasted memory, the site may lose some of the performance benefit and spend more time recompiling PHP files. + +On shared or multi-user hosting, review the [OpCache Security](security.md#opcache-security) guidance before enabling a shared OPcache configuration. + ### Fragment Cache This caching method allows saving sections of otherwise non-cacheable dynamic website content. It can help especially for sites where the majority of the page is static, but has certain dynamic elements, like a shopping cart, or for membership sites. diff --git a/server-environment.md b/server-environment.md index c337dd2..f4bb1db 100644 --- a/server-environment.md +++ b/server-environment.md @@ -331,7 +331,7 @@ The PHP extensions listed below are _recommended_ to allow some WordPress cache - [apcu](https://www.php.net/manual/en/book.apcu.php) – In-memory key-value store for PHP (former APC stripped of opcode caching). - [memcached](https://www.php.net/manual/en/book.memcached.php) (requires libmemcached >= 1.0.0) - memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. -- [opcache](https://www.php.net/manual/en/book.opcache.php) - PHP can be configured to preload scripts into the opcache when the engine starts. +- [opcache](https://www.php.net/manual/en/book.opcache.php) - Stores precompiled PHP bytecode to reduce repeated script parsing and compilation. See [Opcode Cache](performance.md#opcode-cache) for performance guidance. - [redis](https://pecl.php.net/package/redis) - PHP extension for interfacing with Redis. From eb603c0807e728df2ee00ccdeedcd926c5ee0e79 Mon Sep 17 00:00:00 2001 From: Kamran Abdul Aziz Date: Tue, 9 Jun 2026 23:40:57 +0530 Subject: [PATCH 2/3] Mention OPcache interned strings buffer --- performance.md | 1 + 1 file changed, 1 insertion(+) diff --git a/performance.md b/performance.md index b6803cf..1c9e336 100644 --- a/performance.md +++ b/performance.md @@ -82,6 +82,7 @@ As with any cache, opcode caches can keep changes from taking effect until the c For production WordPress environments, OPcache should generally be enabled for web requests and sized for the site or hosting platform. Important [OPcache runtime configuration](https://www.php.net/manual/en/opcache.configuration.php) settings to review include: - `opcache.memory_consumption`, which controls the shared memory available to OPcache. +- `opcache.interned_strings_buffer`, which controls the memory available for interned strings. WordPress and plugins can reuse many strings, so hosts may need to tune this above the PHP default for larger sites. - `opcache.max_accelerated_files`, which controls how many scripts can be cached. - `opcache.validate_timestamps` and `opcache.revalidate_freq`, which control how OPcache checks whether cached PHP files have changed. From 1a302a762ddbbdb6e36cd8304724756a45e3a41e Mon Sep 17 00:00:00 2001 From: Kamran Abdul Aziz Date: Thu, 13 Aug 2026 02:54:22 +0530 Subject: [PATCH 3/3] Apply review wording suggestions Adopts kittenkamala's review suggestions: expand OPcache intro with extension/version detail, soften production recommendation phrasing, and clarify interned strings description. --- performance.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/performance.md b/performance.md index 1c9e336..2fc8914 100644 --- a/performance.md +++ b/performance.md @@ -77,12 +77,12 @@ The web server must read, compile, and run each PHP script. An opcode cache stor As with any cache, opcode caches can keep changes from taking effect until the cache expires or is purged. With opcode cache specifically, this means older versions of the compiled PHP code will be loaded. When updating plugins, themes, or WordPress core, the appropriate files should be purged from the cache to avoid continuing to load the older versions. -[OPcache](https://www.php.net/manual/en/book.opcache.php) is the opcode cache bundled with modern PHP versions. It improves PHP performance by storing precompiled script bytecode in shared memory, which reduces the need to load and parse the same PHP files on each request. +[OPcache](https://www.php.net/manual/en/book.opcache.php) is a PHP extension, bundled with PHP 5.5.0 and later, that acts as a caching mechanism to boost PHP performance. Precompiled script bytecode, low level binary representations of code, are stored in memory, enabling PHP files to be fetched from memory instead of loading and parsing files on each request. -For production WordPress environments, OPcache should generally be enabled for web requests and sized for the site or hosting platform. Important [OPcache runtime configuration](https://www.php.net/manual/en/opcache.configuration.php) settings to review include: +For production WordPress environments, it's recommended that OPcache be enabled for web requests and sized for the site or hosting platform. Important [OPcache runtime configuration](https://www.php.net/manual/en/opcache.configuration.php) settings to review include: - `opcache.memory_consumption`, which controls the shared memory available to OPcache. -- `opcache.interned_strings_buffer`, which controls the memory available for interned strings. WordPress and plugins can reuse many strings, so hosts may need to tune this above the PHP default for larger sites. +- `opcache.interned_strings_buffer`, which controls the memory available for interned strings (distinct string values stored in memory). WordPress and plugins can reuse many strings, so hosts may need to tune this above their standard PHP default to accommodate larger sites. - `opcache.max_accelerated_files`, which controls how many scripts can be cached. - `opcache.validate_timestamps` and `opcache.revalidate_freq`, which control how OPcache checks whether cached PHP files have changed.