OPcache

term

programmingweb dev

Kept in this browser · My desk

PHP's bytecode cache, which keeps compiled scripts in shared memory so PHP does not parse and compile them on every request.

Bundled since PHP 5.5 and always built in and loaded since 8.5, it is shared by every worker and every PHP-FPM pool on a server. With opcache.validate_timestamps off, new code takes effect only after opcache_reset(), opcache_invalidate() or a restart, so a deployment that skips all three keeps serving the old scripts.

Its shared memory segment, sized by opcache.memory_consumption, also holds the buffer of the JIT compiler PHP 8.0 added, which compiles hot code into machine code. PHP's 8.0 release page reported about three times the performance on synthetic benchmarks but typical application performance on par with PHP 7.4, and since PHP 8.4 the JIT is disabled by default.

Because one OPcache instance serves all pools, the PHP manual says FPM pools are not a security mechanism. The opcache.restrict_api setting limits which scripts may call the cache's management functions; its default is no restriction.

Also known as: opcode cache, zend opcache, php jit, opcache.jit, opcache_reset

← Back to O Back to the glossary