What is OPcache in PHP?
Answer
OPcache is a PHP bytecode caching extension bundled with PHP since 5.5. Normally, PHP parses and compiles every source file into opcodes (bytecode) on every request. OPcache stores compiled opcodes in shared memory, so subsequent requests reuse the precompiled bytecode, skipping the parse and compile steps. This significantly reduces CPU usage and request response times — typically 50-70% performance improvement for web applications. Enable in php.ini: opcache.enable=1. Key settings: opcache.memory_consumption (amount of shared memory), opcache.max_accelerated_files (how many files to cache), opcache.revalidate_freq (how often to check if source changed). In production, set opcache.validate_timestamps=0 to disable file change checks entirely for maximum performance.