PHP is an interpreted language — without OPcache, every single request re-parses and re-compiles your PHP source files from scratch. OPcache eliminates that overhead, and it’s one of the single biggest “free” performance wins available.
opcache.enable=1 opcache.memory_consumption=256 opcache.max_accelerated_files=20000 opcache.validate_timestamps=1 opcache.revalidate_freq=2
How It Actually Works
OPcache compiles PHP source into bytecode once and caches that bytecode in shared memory, so subsequent requests skip parsing and compilation entirely and jump straight to execution. On a busy production server, enabling OPcache typically cuts response times dramatically — often 2-3x — for the exact same code.
In Production, Disable Timestamp Validation
# Skip checking file modification times on every request (faster) # Requires manually clearing the cache on deploy instead opcache.validate_timestamps=0
Just remember to reset OPcache (or restart PHP-FPM) as part of your deployment process if you disable timestamp validation, or old cached bytecode will keep serving after a deploy.