Using APC or OPcache with Magento
Magento is a resource‑intensive ecommerce platform, and enabling opcode caching is one of the most effective ways to improve performance. Both APC and OPcache store precompiled PHP code in memory, reducing the need for repeated compilation and speeding up page delivery.
About APC and OPcache
Section titled “About APC and OPcache”-
APC (Alternative PHP Cache)
Section titled “APC (Alternative PHP Cache)”- Works with PHP 5.4 and earlier.
- Requires installation as a separate PHP extension.
- May or may not already be installed on your server.
-
OPcache
Section titled “OPcache”- Built into PHP 5.5 and newer.
- Drop‑in replacement for APC.
- Enabled by default on most modern hosting environments.
Using APC or OPcache with Magento
Section titled “Using APC or OPcache with Magento”-
Check PHP version
Section titled “Check PHP version”- If running PHP ≤ 5.4, APC may be available.
- If running PHP ≥ 5.5, OPcache is recommended.
-
Verify installation
Section titled “Verify installation”- Use
phpinfo()or cPanel’s PHP Info to confirm APC/OPcache status. - Look for sections labeled APC or Zend OPcache.
- Use
-
No Magento configuration required
Section titled “No Magento configuration required”- APC and OPcache operate at the web server level.
- Magento automatically benefits from performance improvements once caching is enabled.
-
Optional tuning (OPcache)
Section titled “Optional tuning (OPcache)”-
Adjust settings in
php.inifor optimal performance:opcache.enable=1opcache.memory_consumption=256opcache.interned_strings_buffer=12opcache.max_accelerated_files=65406opcache.revalidate_freq=2 -
These values can be customized depending on server resources.
-
Important Notes
Section titled “Important Notes”- APC is deprecated; use OPcache if possible.
- Always clear Magento’s cache after enabling or changing opcode caching.
- For more details, see the official PHP OPcache documentation.