# Using APC or OPcache with Magento

> Find out how APC and OPcache speed up Magento by caching compiled PHP code in memory, and how to use them with your store.

Source: https://helpcenter.ruachost.com/apps/magento/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

- ### 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

  - 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

1. ### Check PHP version

   - If running PHP ≤ 5.4, APC may be available.
   - If running PHP ≥ 5.5, OPcache is recommended.
2. ### Verify installation

   - Use `phpinfo()` or cPanel’s PHP Info to confirm APC/OPcache status.
   - Look for sections labeled **APC** or **Zend OPcache**.
3. ### No Magento configuration required

   - APC and OPcache operate at the **web server level**.
   - Magento automatically benefits from performance improvements once caching is enabled.
4. ### Optional tuning (OPcache)

   - Adjust settings in `php.ini` for optimal performance:

     ```
     opcache.enable=1
     opcache.memory_consumption=256
     opcache.interned_strings_buffer=12
     opcache.max_accelerated_files=65406
     opcache.revalidate_freq=2
     ```
   - These values can be customized depending on server resources.

## 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](https://php.net/manual/en/book.opcache.php).
