PHP › Performance Optimization & OPcache
What is OPcache, and how does it improve PHP application performance by caching compiled bytecode?
BeginnerAnswer
OPcache is a built in PHP extension that stores precompiled script bytecode in shared memory, meaning PHP does not need to parse and compile the same PHP source file from scratch on every single request, which significantly reduces CPU usage and improves response times, and enabling OPcache is generally considered one of the single most impactful and easiest performance improvements you can make for any production PHP application.
; php.ini configuration
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000Real-world example A company enables OPcache on their production servers and immediately observes a significant reduction in average response time, since PHP no longer needs to repeatedly parse and compile the exact same application code on every incoming request.