The first request to 1C-Bitrix: PHP reads, parses, and compiles dozens of kernel files. Without OPcache, this happens on every access. On a typical project with 20,000 PHP files, initial compilation takes up to 0.5 seconds. A properly configured OPcache stores bytecode in shared memory, speeding up response by 3–5 times and reducing CPU load by 20–30%. With OPcache, a page loads up to 5x faster than without it — that's a clear comparison. Wikipedia defines OPcache as an opcode cache that can double PHP performance.
According to official PHP documentation, OPcache stores compiled bytecode in shared memory and uses it for subsequent requests, eliminating compilation phases. With over 5 years of experience and 50+ Bitrix projects, we guarantee professional configuration. We have been configuring Bitrix projects for over 5 years and have optimized OPcache for 50+ sites of varying complexity. Let's break down why standard PHP parameters don't fit Bitrix, how to set optimal values, and how to automate cache clearing on deploy.
Why Default OPcache Settings Don't Fit 1C-Bitrix
Default PHP parameters are designed for an average application that includes 10–20 files per request. In Bitrix, it's 200–400 files. Because of this, OPcache quickly fills up, the cache is evicted, and compilation repeats. As a result, the hit rate drops below 85%, and the server wastes resources on recompilation. Proper OPcache optimization for Bitrix requires careful tuning.
Diagnosing the current state is the first step. PHP OPcache diagnostics is critical. Use this script:
$status = opcache_get_status(); echo "Cached files: " . $status['opcache_statistics']['num_cached_scripts'] . "\n"; echo "Cache full: " . ($status['cache_full'] ? 'YES' : 'NO') . "\n"; echo "Hit rate: " . round($status['opcache_statistics']['opcache_hit_rate'], 2) . "%\n"; echo "Memory used: " . round($status['memory_usage']['used_memory'] / 1024 / 1024, 1) . " MB\n"; echo "Memory free: " . round($status['memory_usage']['free_memory'] / 1024 / 1024, 1) . " MB\n"; If cache_full = YES, increase memory_consumption. If hit rate is below 90%, check if the cache is being cleared on deploy.
Step-by-Step OPcache Configuration for 1C-Bitrix
Follow these steps to configure OPcache for your Bitrix site. This PHP configuration for 1C-Bitrix ensures optimal performance. Bitrix OPcache caching is essential for performance.
- Check current status – Run the diagnostic script above to identify issues.
-
Set optimal parameters – Edit
php.iniwith recommended values (see table below). - Enable huge pages – If your Linux kernel supports it, enable
opcache.huge_code_pagesfor extra CPU savings. - Restart PHP-FPM – Apply changes with
systemctl reload php8.1-fpm. - Monitor hit rate – Use opcache-gui or Prometheus to ensure hit rate stays above 95%.
In the php.ini file (or /etc/php.d/10-opcache.ini), set parameters for Bitrix. Recommended values:
| Parameter | Recommendation for Bitrix | Explanation |
|---|---|---|
opcache.memory_consumption |
192 MB | For Enterprise — 256 MB, for Business — 128 MB |
opcache.interned_strings_buffer |
16 MB | For storing string constants |
opcache.max_accelerated_files |
32531 | Must exceed the total number of PHP files |
opcache.validate_timestamps |
0 | On production — maximum speed |
opcache.revalidate_freq |
60 | Not used when validate_timestamps=0 |
opcache.huge_code_pages |
1 | Enable for huge pages |
opcache.optimization_level |
0x7FFEBFFF | AST optimization |
opcache.file_cache |
/tmp/opcache | Backup file cache |
opcache.restrict_api |
/var/www | Restrict clearing from code |
Example configuration:
[opcache] opcache.enable = 1 opcache.enable_cli = 0 opcache.memory_consumption = 192 opcache.interned_strings_buffer = 16 opcache.max_accelerated_files = 32531 opcache.revalidate_freq = 60 opcache.validate_timestamps = 0 opcache.optimization_level = 0x7FFEBFFF opcache.huge_code_pages = 1 opcache.file_cache = /tmp/opcache opcache.restrict_api = /var/www How to Clear OPcache on Deploy
With validate_timestamps = 0, OPcache does not check file changes. After code updates, clearing is required. The most reliable method is restarting PHP-FPM:
systemctl reload php8.1-fpm Programmatic clearing via CLI (only if CLI uses the same OPcache as FPM):
php -r "opcache_reset();" For automation, add a script with access limited to localhost:
<?php if ($_SERVER['REMOTE_ADDR'] !== '127.0.0.1') { http_response_code(403); exit; } opcache_reset(); echo "OPcache reset OK\n"; Include a call to this script in the deploy process (after file updates).
How to Interpret OPcache Metrics
| Metric | Green status | What to do if bad |
|---|---|---|
| Hit rate | >95% | Increase memory_consumption or check clearing |
| Cache full | NO | Increase memory_consumption |
| Used memory | <80% of allocated | Increase memory_consumption |
| OOM errors | 0 | Increase memory or huge pages |
Additional Information
For high-load projects, additionally use monitoring via Prometheus with the ORC exporter or install opcache-gui. This allows tracking hit rate in real time.What's Included in Turnkey OPcache Configuration
We perform a full cycle of work:
- Diagnostics of the current OPcache and server state.
- Selection of parameters for your project (PHP version, number of files, load).
- Configuration of
php.iniand PHP-FPM pool. - Enabling huge code pages on Linux (if kernel supports).
- Automation of cache clearing on deploy.
- Installation of monitoring (opcache-gui or integration with Prometheus/Grafana).
- Documentation and recommendations for further optimization.
After configuration, you get a stable hit rate >95% and reduced response time. We guarantee performance improvement — typical configuration costs $350 and can save up to $1,000 per month on server infrastructure. Our experience: 5+ years, 50+ Bitrix projects, 5 years on the market. Order professional configuration to avoid common mistakes. Contact us for an assessment—we'll discuss details and choose the optimal solution.
Estimated Timelines and Cost
Configuration takes from 1 to 3 business days depending on the server infrastructure complexity. Cost is calculated individually after analyzing your project. Contact us for an assessment—we'll discuss details and choose the optimal solution.
Common OPcache Configuration Mistakes
- Too small
memory_consumption— cache overflows, hit rate drops. -
max_accelerated_filesless than the actual number of PHP files — some files are not cached. -
validate_timestampsenabled on production — extra checks on every request. - No automation of cache clearing on deploy — code changes are not applied.
- Forgot to enable
huge_code_pageson Linux — loss of 5–15% CPU performance.
Avoiding these mistakes will yield maximum benefit from OPcache. If you need help, order professional configuration.

