deployment and operations

OPcache In Production

OPcache improves PHP performance by storing precompiled bytecode in shared memory so scripts do not need to be parsed on every request. Production deploys must account for cache refresh behaviour.

Match Cache Refresh To Deployment

  • Enable OPcache for served PHP runtime.
  • Review memory and accelerated-file capacity.
  • Choose timestamp validation or explicit reset strategy deliberately.

Verify New Code And Rollback

  • Inspect effective OPcache config.
  • Deploy changed code in staging.
  • Verify new code is served and rollback works.

Inspect The Serving Runtime

  • Stale cached bytecode can serve old code.
  • CLI and FPM OPcache settings differ.
  • Too-small capacity reduces benefit.

OPcache Settings To Review

opcache.enable = 1
opcache.memory_consumption = 128
opcache.max_accelerated_files = 10000
opcache.validate_timestamps = 1
opcache.revalidate_freq = 2

OPcache is ready when configuration and deployment invalidation match the release strategy. Inspect FPM rather than assuming CLI settings prove what served requests are using.

Practice

Practice: Review OPcache Deployment

Review how a deployment makes changed PHP files visible when OPcache is enabled, then describe how rollback is checked.

Requirements

  • Enable OPcache for served PHP runtime.
  • Review memory and accelerated-file capacity.
  • Choose timestamp validation or explicit reset strategy deliberately.
  • Inspect effective OPcache config.
  • Deploy changed code in staging.
  • Verify new code is served and rollback works.
Show solution

Inspect the effective OPcache configuration in the serving runtime. Choose timestamp validation or an explicit refresh strategy that matches deployment, then release a visible staging change and prove that FPM serves the new code.

Roll back and verify the previous code as well. CLI output alone is insufficient because CLI and FPM OPcache settings can differ.