Glossary

OPcache

OPcache is a built-in PHP extension that stores compiled bytecode in shared memory. Instead of parsing and compiling the same file on every request, PHP does it once — then reads the result from memory. The typical gain is 2–5× higher throughput with zero changes to your code.

How it works

The first time PHP executes a script, it compiles the source into bytecode (opcodes) and writes it to shared memory. All subsequent requests — even from different worker processes — read the pre-compiled bytecode directly, bypassing the lexer, parser, and compiler entirely.

Key directives

Cache invalidation

In production with validate_timestamps = 0, OPcache is unaware of file changes. After a deploy you must flush it manually. The cleanest approach is restarting PHP-FPM. When that is not an option, call opcache_reset() or opcache_invalidate($path, true) from a post-deploy script.