Difference between APC, APCu and Opcache?

Difference between APC, APCu and Opcache?

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Difference between APC, APCu and Opcache?

When upgrading from a legacy PHP environment to modern distributions like Ubuntu 14.04, you will almost certainly encounter a confusing landscape of memory caching modules. The source material highlights a specific transition: moving from php-apc 3.1.7 on an older system to finding both php-apc and php5-apcu available on the new server, while simultaneously seeing "Zend OPcache" listed in the build information.

To understand which tool serves your application, you must first distinguish between what these acronyms represent. APC stands for Alternative PHP Cache. Originally, it was a single monolithic extension that handled two distinct tasks: bytecode caching (compiling PHP code into optimized binaries) and user variable caching (storing data arrays in shared memory).

In the modern ecosystem, this monolith has been split into two separate components to allow for better maintenance and performance tuning. This is where the confusion arises regarding apc versus apcu.

APCu stands for Alternative PHP Cache User Space. It is a fork of the original APC project that separated the bytecode caching functionality from the user variable caching.

  • OPcache handles bytecode caching. It compiles your .php files into optimized C code and stores them in memory. This prevents the server from parsing and compiling code on every request, significantly reducing CPU load for static logic. The output of php -v confirms this is present: "with Zend OPcache v7.0.3". On Ubuntu 14.04 with PHP 5.5, OPcache is often enabled by default, so you likely do not need to manually configure APCu for bytecode caching.
  • APCu handles user variable caching. It allows you to store associative arrays and objects in shared memory (apc_user_cache or apc_sma). This is useful for storing computed data that varies per session but doesn't need database round-trips, such as complex API results or configuration arrays.

The source material mentions using a class called "kickasscache" to save CPU and memory. The developer notes that phpinfo() shows "apc" as emulated. This is a critical diagnostic clue. On the new server, if you see both packages installed but the output suggests emulation, it usually means the OPcache extension is active (which it is), but the APCu extension might not be properly loaded or configured for user variables.

If your goal is purely bytecode caching to reduce CPU usage during compilation, OPcache is sufficient on its own. You do not need to install the php5-apcu package unless you specifically require shared memory storage for application data. In fact, running both OPcache and APCu simultaneously can sometimes lead to configuration conflicts if not managed carefully, though they generally operate in parallel without direct interference.

However, there is a significant trade-off with user variable caching (APCu) that developers must consider: data consistency. When you store a large array in APCu, any process that writes to the database after the cache is populated will serve stale data until the cache entry expires or is manually flushed. With OPcache, if you modify the source code of a script, the new bytecode is automatically picked up on the next request (subject to max_accelerator_lifetime settings). With APCu, your application logic must explicitly handle cache invalidation (apc_delete() or apc_clear_cache()) when data changes.

For high-traffic sites like the one described with 100k daily unique visits, relying solely on APCu for heavy data lifting can lead to memory exhaustion if eviction policies aren't tuned correctly. The "kickasscache" class mentioned in the source material likely implements a sophisticated invalidation strategy or uses a different backend entirely. If you wish to replicate that behavior with APCu, you must ensure your application explicitly manages cache keys and TTLs (Time To Live).

If you decide to stick with the built-in OPcache for bytecode and skip APCu entirely, your setup is often more stable for standard web applications. You can configure OPcache parameters like opcache_max_accelerator_size in /etc/php/5.5/fpm/conf.d/10-opcache.ini to ensure you don't exceed your RAM limits. For user data caching, consider using a dedicated Redis or Memcached instance instead of relying on the PHP memory space. This offloads the burden from the web server and provides better scalability as traffic grows.

In summary, "APC" in legacy terms referred to the all-in-one solution. Today, you are likely looking at OPcache for code performance and APCu (or a Redis/Memcached alternative) for data caching. If your primary bottleneck is CPU during script parsing, OPcache handles that by default on modern Ubuntu setups. You only need APCu if you have a specific requirement for shared memory user variables and can manage the complexity of cache invalidation yourself.

Our network