PHP theorytheory 0/50 · 0%
Performance · hard

38. OPcache & Performance

Speeding up PHP execution.

OPcache compiles PHP scripts into bytecode and caches it in shared memory, avoiding the cost of re-parsing and re-compiling source files on every request; it's essential for production performance. Preloading (opcache.preload, PHP 7.4+) can load classes/functions into memory once at server startup for even faster subsequent requests.

Profiling tools like Xdebug or Blackfire help locate real bottlenecks (often database queries or N+1 patterns) rather than guessing, since PHP itself is rarely the slowest part of a typical web request.

Check your understanding

  1. 1. What does OPcache primarily cache?

  2. 2. What PHP 7.4+ feature loads code into memory once at server startup?