APC Cache Optimization & Monitoring Using Web Interface

While we installed PHP with other things, we also installed a php-apc package.

APC is one of the most popular caching mechanism for PHP’s op-code caching. Once activated, it starts caching PHP codes automatically. It also works nicely with W3 Total Cache plugin for storing Object & MySQL caches.

APC – Web-based User Interface

Its always better to check if APC is working correctly. Thankfully, APC comes with file apc.php, which provides a simple web-based interface. Just copy it to your site’s web-root folder:

cp /usr/share/doc/php-apc/apc.php /var/www/example.com/htdocs

Then open http://example.com/apc.php in browser.

In case you want to use admin-side of apc.php, you will need to change default password to something else.

Just open apc.php file and edit following line:

defaults('ADMIN_PASSWORD','password');          // Admin Password - CHANGE THIS TO ENABLE!!!

You can change a few more defaults to customize web-based UI as per your needs.

APC Cache Configuration

You can tweak APC’s parameter by editing vim /etc/php5/conf.d/20-apc.ini (if you have installed PHP this way). In other cases, you can simply add following values to your php.ini

If apc.php is showing miss-rate above 10%, the chances are high that you need to change value of some APC configuration option.

There are many APC configuration options, but I recommend making changes to the following:

Total RAM storage allocated for APC (default is 32 MB)


Maximum size of a single file APC can store (default is 1MB)


Number of op-code “files” APC can store (default is 1000)


Number of data entries APC can store (default is 4096)


Once you are done with tweaking, you need to restart PHP. Command: service php5-fpm restart

APC & WordPress + WP3 Total Cache

If you are using W3 Total Cache plugin, then you must make use of APC for Database Cache and Object Cache. 

Check following screenshot:

Note: W3 Total cache will offer APC storage option for Page Cache and Minify Cache also. Do NOT use it. “Disk enhanced” is better for Page Cache & Minify Cache.

There are many caching engines available for PHP but I like APC for its simplicity. Also APC will be official caching mechanism for PHP 6 (someday…)


18 responses to “APC Cache Optimization & Monitoring Using Web Interface”

  1. Hey there,

    Up to now, the following is wrong:


    The apc.shm_size parameter has to be extended with a size unit, e.g. M or G:





    • @Pascale

      Thanks for pointing it out. I will update it now. 🙂

      What I used was old-syntax. Its not wrong. It still works but generates warning.

  2. In your final note you mention not to use Opcode APC for Page cache. But when I use “Page cache: Disk Enhanced”, my SSL sites break, and the style sheets aren’t loaded. APC option seems to be working, can you elaborate on why I shouldn’t be using it, or how I might solve the SSL problem with Disk Enhanced? Thanks for the excellent tutorials.

  3. i’m sorry, that was browser cache that i was having problems with, and it seems o be resolved. you can delete my comments here. thanks.

  4. Are you sure about values for apc.shm_size and espacially apc.max_file_size. Most webservers for small blogs don’t have so much RAM, that they can reserve 1G only for APC. Like my V-Server only has 1G running a multisite installation. I have only 96M fpr APC and even the caching plugin (Cachify) stores it’s values into APC, my cache is only 50% filled. Even though giving APC lots of RAM lowers the RAM usage of the Apache processes, I would save enough RAM for other processes like Apache and MySQL-

    I also wouldn’t recommend to set the max_file_size to such a high value (unless you really have 1G for APC). The largest file in the WordPress core ist only like 180K, so even the default value of 1M is more than enough.

  5. Hi Guys,

    I have centos server and php 5.4.22. I am facing some problem with the file cache info. while User Cache Information is working perfectly. as soon as I installed the apc and updated the settings, I got 100% green bar and 0% misses. Is this correct? below is the setting that I have used so far. Please help me to correct it so that file caches also start working.


  6. I am no longer using APC. We switched to zend-opcache starting from PHP 5.5 – http://rtcamp.com/tutorials/php/zend-opcache/

    However, it’s possible to have 100% hits if nothing is getting modified on your server. Like a single-user blog using 3rd party commenting system.

    You can inspect what is cached in APC using web-viewer. There are two big buttons with text “System Cache Entries” and “User Cache Entries” for file-cache and user-cache. respectively.

    You can also comment out your custom APC config and switch back to default APC config. It might make a difference as well.

  7. I am new to using APC. I have set apc.shm_size as 64M. I’m confused what could be the right value for apc.ttl value for a websies which gets hardly 200 visitors per day?

    • I think you can leave it default. Size and TTL are not dependent on each other. Size controls how “much” you can cache and TTL controls how “long” you can cache!

  8. Hi,
    where to download the apc.php web interface? The php5-apc package of Debian does not have anything but the changelog in /usr/share/doc/php5-apc/.