PHP OPcache FAQ
Introduction
The PHP Group describes PHP OPcache as improving PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.
To learn more about the overwhelming benefits of using OPcache we suggest starting with this AppDynamics article: Why Every PHP Application Should Use an OpCache
Configuring OPcache
Complete runtime configuration is provided to each cPanel account by default. Methods of configuration include exposing OPcache functions for scripts, allowing configuration controls within .htaccess files, and directly within cPanel.
Flush OPcache
Flushing OPcache on demand is recommended for most situations
-
Create a
PHPfile with the following code:<?php opcache_reset(); print("Done."); ?>
That's it! Now, any time you request that
PHPscript in your browser it will flush the server side cache, so that you can keep the performance benefits in place, while also ensuring anyPHPcode changes are brought into effect as required.
Tip
More details about PHPs opcache_reset function can be found in the PHP Manual for opcache_reset along with further code snippets and examples.
Toggle OPcache On/Off
Generally completely disabling OPcache in this way is not recommended
Within cPanel Navigate to Select PHP Version:
Next, simply Check or Uncheck the opcache (and zend_guard_loader if present) extensions and then Save to apply the change:
Further Resources
Still in need of help? For speedy assistance our friendly staff are always ready to help via our helpdesk, on Twitter, through our website, or directly via email to support.

