August 20, 2026 · by CLIQHOST
If you run a WordPress, Joomla, or any PHP-based application and want to speed it up without investing in additional hardware, PHP OPcache is one of the most effective tools available. Bundled with PHP since version 5.5, it can reduce server response times by 50–80% with just a few configuration changes.
In this guide, you'll learn exactly what OPcache does, how to enable it, and how to configure it properly — whether you're on an NVMe VPS with root access or a cPanel shared hosting environment.
Every time your server receives a PHP request, the interpreter must:
.php file from diskSteps 1 and 2 happen on every single request, even when the code hasn't changed. OPcache eliminates recompilation by storing the compiled bytecode directly in RAM. On subsequent requests, PHP skips straight to execution.
The result: lower CPU usage, faster response times, and higher throughput capacity.
On an SSD VPS with SSH access, run:
php -r "echo opcache_get_status() ? 'OPcache active' : 'OPcache inactive';"
Alternatively, create a temporary PHP info file:
echo '<?php phpinfo(); ?>' > /var/www/html/info.php
Open https://yourdomain.com/info.php in your browser and look for the Zend OPcache section. Delete the file immediately after checking — it exposes sensitive server information.
On cPanel, you can check active extensions via MultiPHP INI Editor or PHP Selector.
Locate your php.ini file:
php --ini | grep "Loaded Configuration"
Open the file and add or uncomment:
extension=opcache
zend_extension=opcache
Restart PHP-FPM or Apache:
# For PHP-FPM
systemctl restart php8.2-fpm
# For Apache with mod_php
systemctl restart apache2
opcache.enable and set it to 1This is where the difference lies between an active OPcache and a well-configured one. Add these directives to your php.ini or a dedicated file like /etc/php/8.2/fpm/conf.d/10-opcache.ini:
; Enable OPcache
opcache.enable=1
opcache.enable_cli=0
; Allocated memory (MB) — recommended: 128–256 MB
opcache.memory_consumption=128
; Interned strings buffer size
opcache.interned_strings_buffer=16
; Maximum number of cacheable files
opcache.max_accelerated_files=10000
; Revalidation interval (seconds). 0 = manual reset only
opcache.revalidate_freq=60
; Timestamp validation (1 = yes, 0 = max perf, manual reset needed)
opcache.validate_timestamps=1
; Save comments (required by some annotation-based frameworks)
opcache.save_comments=1
; Disk-based file cache (fallback after server restart)
opcache.file_cache=/tmp/opcache
opcache.file_cache_consistency_checks=1
| Directive | Recommended Value | Explanation |
|---|---|---|
memory_consumption |
128–256 MB | RAM reserved for bytecode cache |
max_accelerated_files |
10 000–20 000 | WordPress + plugins = thousands of files |
revalidate_freq |
60 (prod) / 0 (dev) | How often to check for file changes |
validate_timestamps |
1 | Auto-detect modified files |
A typical WordPress install with plugins can generate 3,000–8,000 PHP files. Add WooCommerce, child themes, and page builders, and that number climbs quickly.
Recommended settings for a WordPress site on optimized WordPress hosting:
opcache.memory_consumption=192
opcache.max_accelerated_files=15000
opcache.revalidate_freq=300
opcache.fast_shutdown=1
After every theme or plugin update, manually flush the OPcache. A simple script:
<?php
if (function_exists('opcache_reset')) {
opcache_reset();
echo 'OPcache successfully flushed.';
}
Or using WP-CLI (recommended on a VPS):
wp eval 'opcache_reset();' --allow-root
Get detailed statistics with opcache_get_status():
<?php
$status = opcache_get_status();
echo 'Memory used: ' . round($status['memory_usage']['used_memory'] / 1024 / 1024, 2) . ' MB\n';
echo 'Cached scripts: ' . $status['opcache_statistics']['num_cached_scripts'] . '\n';
echo 'Hit rate: ' . round($status['opcache_statistics']['opcache_hit_rate'], 2) . '%\n';
A healthy hit rate is above 90%. If it's lower:
- Increase memory_consumption
- Increase max_accelerated_files
- Check whether validate_timestamps is causing frequent cache invalidations
For a visual dashboard, install the free opcache-gui tool directly on your server.
opcache.validate_timestamps=1
opcache.revalidate_freq=300
opcache.validate_timestamps=1
opcache.revalidate_freq=0
Or disable OPcache entirely in dev to see changes instantly:
opcache.enable=0
On a production NVMe VPS, never set both revalidate_freq=0 and validate_timestamps=0 simultaneously without an automated cache reset mechanism on deploy.
If memory_consumption is too low (e.g., 32 MB), the cache fills up quickly and performance degrades. Check real usage with opcache_get_status() and adjust accordingly.
max_accelerated_files Too LowThe default value of 2,000 is insufficient for WordPress. Set it to at least 10,000.
If you update PHP files but OPcache is still serving the old version, you'll see unexpected behavior or errors. Integrate opcache_reset() into your deploy script or CI/CD pipeline.
On quality shared hosting — like CLIQHOST's cPanel hosting — OPcache is configured with per-user isolation, meaning one account's cache cannot affect another.
For full server management support and custom OPcache tuning, consider our server management services.
OPcache optimizes PHP execution (server-side). For complete performance, combine it with:
This combination can bring response times below 200ms even under heavy traffic. If you need full control over your entire stack, a managed dedicated server gives you the resources and flexibility to fine-tune every layer.
For more performance tips and server guides, visit the CLIQHOST blog.
PHP OPcache is one of the simplest and most impactful optimizations you can make for any PHP server. A few well-chosen directives in php.ini can significantly reduce CPU load and improve response times at zero additional cost.
The essential steps:
1. Verify OPcache is enabled
2. Allocate enough RAM
3. Set max_accelerated_files to match your application's size
4. Reset the cache after every deployment or update
5. Monitor the hit rate and tune periodically
If you want a hosting environment where OPcache is correctly configured from day one, explore NVMe VPS plans or WordPress hosting from CLIQHOST — or contact us for a custom server setup.
Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.
"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."
"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."
"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."