Interview question
What is OPcache and how does it improve PHP performance? OPcache क्या है और यह PHP performance कैसे बेहतर बनाता है?
Answer
OPcache is a built-in PHP extension that stores precompiled script bytecode in shared memory, eliminating the need to parse and compile PHP files on every request.
Without OPcache: Request → Read file from disk → Lex/Parse → Compile to bytecode → Execute (every single request)
With OPcache: Request → Check shared memory for cached bytecode → Execute directly (skip parse/compile)
With OPcache: Request → Check shared memory for cached bytecode → Execute directly (skip parse/compile)
; php.ini
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.validate_timestamps=0 ; disable in production for max speedEnabling OPcache typically gives a significant performance boost (often 2-3x) with essentially no code changes required.
OPcache एक built-in PHP extension है जो precompiled bytecode को shared memory में store करता है, हर request पर parse/compile करने की ज़रूरत नहीं रहती।
OPcache के बिना: हर request पर file पढ़ना, parse, compile, execute
OPcache के साथ: Shared memory से cached bytecode सीधे execute
OPcache के साथ: Shared memory से cached bytecode सीधे execute
opcache.enable=1
opcache.memory_consumption=128
opcache.validate_timestamps=0Was this answer clear?