Performance optimization is an important part of managing PHP applications and web servers. In earlier PHP environments, Alternative PHP Cache (APC) was one of the most widely used caching solutions for improving application speed and reducing server load.
APC worked by storing compiled PHP bytecode in shared memory, eliminating the need to recompile PHP scripts on every request. This significantly improved performance for dynamic PHP applications.
However, APC is now deprecated and unsupported in modern PHP environments. Today, OPcache and APCu are the recommended alternatives for PHP caching and performance optimization.
In this blog, we’ll explain what APC was, how it worked, why it became obsolete, and which modern caching solutions should be used instead.
What Is Alternative PHP Cache (APC)?
Alternative PHP Cache (APC) was an open-source PHP accelerator and caching framework designed to improve PHP execution performance.
When PHP scripts run, PHP first compiles the code into intermediate bytecode instructions called opcodes. APC stored these compiled opcodes in memory so future requests could reuse them directly without recompilation.
This process reduced:
- CPU usage
- Script execution time
- Server load
- Response latency
As a result, websites and PHP applications became faster and more efficient.
How APC Worked
Normally, PHP performs these steps whenever a script is executed:
- Read the PHP script
- Compile it into opcodes
- Execute the opcodes
- Return the output
Without caching, PHP repeats this process for every request.
APC improved performance by caching the compiled opcode in shared memory. Future requests reused the cached version instead of recompiling the script again.
This reduced overhead and improved application performance considerably.
Why APC Is Deprecated
Although APC was extremely popular in older PHP versions, it is no longer recommended for modern environments.
Main Reasons APC Is Obsolete
- APC does not support modern PHP versions
- The project is no longer maintained
- Modern PHP includes better built-in solutions
- Current Linux distributions no longer package APC
- Security and compatibility issues exist with newer PHP releases
Because of these limitations, APC should not be used on modern production servers.
Modern Alternatives to APC
The original APC functionality was separated into two dedicated solutions:
- OPcache → Opcode caching
- APCu → User data caching
These are now the standard PHP caching solutions.
1. OPcache (Recommended Opcode Cache)
OPcache is the official PHP opcode caching extension built directly into PHP.
It stores precompiled PHP bytecode in shared memory, reducing script compilation overhead and improving performance.
Benefits of OPcache
- Built into modern PHP versions
- Faster PHP execution
- Reduced CPU usage
- Lower server load
- Improved response times
Enabling OPcache
Edit your php.ini file:
zend_extension=opcache.so Restart the web server after making changes.
Verify OPcache using:
php -v You can also confirm it through phpinfo().
2. APCu (User Cache)
APCu is designed for caching application-level data such as variables, objects, and query results.
Unlike OPcache, APCu does not cache PHP bytecode.
Installing APCu
Install APCu using PECL:
pecl install apcu Add the extension to php.ini:
extension=apcu.so Restart the web server to apply changes.
Legacy APC Installation (Old Systems Only)
Some very old servers still running unsupported PHP versions may continue using APC for legacy applications.
Legacy APC Installation Steps
- Download APC from PECL
- Extract the package
- Run
phpize - Configure and compile the extension
- Add the extension to
php.ini - Restart the web server
Example
extension=apc.so These steps are obsolete and should only be used for maintaining old systems.
Verifying PHP Caching
After enabling OPcache or APCu, verify the configuration using:
phpinfo() Look for:
- Zend OPcache section
- APCu section
This confirms the extensions are loaded correctly.
OPcache vs APCu
| Feature | OPcache | APCu |
|---|---|---|
| Purpose | Opcode caching | User data caching |
| Included with PHP | Yes | No |
| Improves PHP execution speed | Yes | No |
| Stores application variables | No | Yes |
| Recommended for production | Yes | Yes |
In most modern PHP environments, both OPcache and APCu are used together for maximum performance optimization.
Conclusion
Alternative PHP Cache (APC) played a major role in improving PHP application performance in earlier versions of PHP. However, it is now deprecated and unsupported for modern systems.
Today, OPcache is the standard solution for PHP opcode caching, while APCu provides efficient in-memory caching for application data. Together, they offer better performance, stability, compatibility, and security compared to the old APC extension.
For modern PHP deployments, administrators should always use OPcache and APCu instead of APC to ensure optimized and secure server performance.
If you require help, contact SupportPRO Server Admin

