On every request PHP reads a file, parses it, compiles it to opcodes and then runs them. Without OPcache that happens for every file on every visit, and a WordPress or Laravel site loads hundreds of files per request. With OPcache, compilation happens once and later requests run the stored version directly.
Key settings
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.validate_timestamps=1
opcache.revalidate_freq=2
| Setting | Meaning |
|---|---|
memory_consumption |
Memory reserved for compiled code, in MB |
max_accelerated_files |
Maximum number of files it can store |
validate_timestamps |
Whether it checks files for changes (1 = yes) |
revalidate_freq |
How often, in seconds, it checks |
These are the defaults in modern PHP versions; they go in php.ini.
Practical example: is it working?
<?php
$s = function_exists('opcache_get_status') ? opcache_get_status(false) : false;
echo $s ? 'OPcache on, cached scripts: ' . $s['opcache_statistics']['num_cached_scripts'] : 'OPcache off';
Upload this file temporarily, open it in the browser, then delete it. Don’t rely on php -i alone: the command line has its own opcache.enable_cli setting, off by default, and may load a different ini file than the website.
Common problems and confusions
- Changes don’t appear right away: with
validate_timestamps=0, PHP won’t see new files until it restarts or the cache is reset. With 1, a change can lag by up torevalidate_freqseconds. - Memory full: if OPcache memory or the file limit is exhausted, PHP keeps recompiling and the benefit drops.
- OPcache is not a page cache: it stores code only, not database results or HTML. It works alongside page caching such as LSCache and doesn’t replace it.
- JIT: PHP 8 added a JIT compiler inside OPcache; for ordinary websites its gain is small compared with heavy number crunching.
On ArabyHost
Every plan runs PHP 8.1 to 8.3 on LiteSpeed, and you can pick the version per site (see choosing a PHP version). On AI/Developer plans you get SSH and Composer to inspect settings and run your tools; on other plans, use the check file above. If an error appears after a deploy, the Araby AI assistant in the panel reads the error log and explains the fix.
FAQ
Is OPcache enabled by default?
It has been bundled with PHP since version 5.5, and most hosts enable it for websites. Check its status with a phpinfo() page or the opcache_get_status() function.
How do I clear the OPcache?
Call opcache_reset() from a PHP page, or restart PHP. If file timestamp validation is on, simply waiting a few seconds is usually enough.
Is OPcache enough to speed up WordPress?
Not on its own. It cuts PHP execution time, but page caching, image optimisation and database tuning have a bigger effect on overall speed.