How does OPcache improve performance, and what are the risks of 'stale' code in a production environment?
Last updated
OPcache stores compiled bytecode (opcodes) in shared memory, so PHP skips reading, parsing and compiling files on every request.
With
opcache.validate_timestampsoff, PHP never checks file changes, so a deploy keeps serving stale old code until the cache is reset.Reset on deploy via
opcache_reset(), a PHP-FPM reload or atomic symlink swaps. Alternatively keep timestamp validation on withrevalidate_freqat a small cost.