OPcache: Enabling & Tuning

2 min read

Overview #

OPcache is PHP’s built-in bytecode cache. It stores compiled PHP scripts in memory so the server doesn’t recompile every file on every request. It’s one of the highest-impact performance settings available: commonly up to 3x faster PHP execution: and it’s standard on properly configured production WordPress hosts.

The Alerts #

Alert Meaning
OPcache Disabled (warning) The extension is installed but not active
OPcache Missing (warning) The extension isn’t installed at all

What OPcache Does #

Without OPcache With OPcache
Every PHP file recompiled per request Compiled bytecode reused from memory
High CPU usage, slow execution Fast execution, low CPU usage
Wasted server capacity Headroom for real traffic

Enabling / Installing #

  • GridPane: PHP extensions are managed in the control panel: enable opcache there (Xponent does this for you).
  • Shared hosting: check with your host; most modern panels (cPanel/Plesk) have an OPcache toggle in PHP settings.
  • Manual (php.ini):
zend_extension=opcache.so
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=2
opcache.validate_timestamps=1

Expected Hit Rates #

A healthy OPcache shows a hit rate of 95%+. Lower hit rates usually mean:

Hit rate Likely cause
< 90% Memory too small (opcache.memory_consumption), or revalidation too aggressive
80-90% Many files, cache thrashing: raise memory and max_accelerated_files
Very low opcache.validate_timestamps + revalidate_freq=0 forcing recompiles

You can see hit rate via a phpinfo() page (OPcache section) or WP-CLI (wp eval 'opcache_get_status()').

Important Warning #

With validate_timestamps=1 and a short revalidate_freq, PHP checks file mtimes: changes appear within seconds. If a host disables timestamp validation for performance, new code won’t appear until OPcache is flushed (which is why some hosts purge cache after deploys). Xponent tunes this so your updates appear immediately while keeping the cache effective.

What You Should Do #

Nothing. If your host doesn’t support installing PHP extensions, that’s a strong signal it’s time to migrate to Xponent, where the full performance stack is managed.

Related Articles #

Updated on August 31, 2026