Contents
What is OPcache Magento2?
OPcache is a code caching module, which improves PHP performance. It uses shared memory to store precompiled script bytecode, as a result there is no need for PHP to load and parse scripts on every request. OPcache is bundled with PHP starting from 5.5. 0.
How do I use OPcache in PHP?
OPCache can only be compiled as a shared extension under this version. Firstly, you need to enable the building of default extension with –enable-opcache option to make it available. Afterwards, you can use the zend_extension configuration directive to lead the OP Cache extension into PHP.
How do you flush OPcache?
To clear the Opcache on CLI, just restart your PHP command. It’s usually as simple as CTRL+C to abort the command and start it again. For the same reason as running PHP as CGI or FastCGI above, having Opcache enabled for CLI requests would hurt performance more than you would gain benefits from it.
Do you need to enable Opcache in Magento 2.1?
Enable opcache.save_comments, which is required for Magento 2.1 and later. We recommend you enable the PHP OPcache for performance reasons. The OPcache is enabled in many PHP distributions. Magento 2.1 and later use PHP code comments for code generation.
What are the PHP settings for Magento 2?
Increase the values for the PHP realpath_cache_size and realpath_cache_ttl to recommended settings: These settings allow PHP processes to cache paths to files instead of looking them up each time a page loads. See Performance Tuning in the PHP documentation. Enable opcache.save_comments, which is required for Magento 2.1 and later.
Where are the Opcache settings located in PHP?
PHP OPcache settings are typically located either in php.ini or opcache.ini. The location might depend on your operating system and PHP version. The OPcache configuration file might have an opcache section or settings like opcache.enable. Use the following guidelines to find it: