Since this is probably common knowledge by now, this blog post is more a note to my future self. APC is dead. Don’t use it. Use OPcache instead. APCu is something else.
In the last few years I’ve had so much issues with APC, that I eventually stopped installing it on my servers by default. Now that I need to squeeze every bit of performance for one of the projects, I looked back at it. And tried it. And once again it kicked me in the balls. Then I remembered that I’ve seen APCu somewhere. Maybe it’s a newer fork or something.
Gladly, after a quick Google search for the difference, I came across this discussion, which clarified a few things.
So out of those you named:
- APC is opcode cache and data store
- APCu is only data store
- OPcache is only opcode cache
Since APC is older, at the moment you likely want OPcache as well as some data store, not necessarily APCu (although it is perfectly fine choice).
My interest was in opcode cache, since I already had a data store. Installing and configuring OPcache needed just a few seconds, and didn’t cause any issues so far.
And if you want more information about it, here is a useful article, which, among other things, lists the helpful tools for monitoring and tweaking OPcache configuration.
3. How to check if OpCache is actually caching my files?
If you have already installed and configured OpCache, you may find it important to control which PHP files are actually being cached. The whole cache engine works in the background and is transparent to a visitor or a web developer. In order to check its status, you may use one of the two functions that provide such information: opcache_get_configuration() and opcache_get_status(). Fortunately, there is a couple of prepared scrips that fetch all the OpCache configuration and status data and display it in a friendly way. You don’t need to write any code by yourself, just pick up one of tools from these below:
– Opcache Control Panel,
– opcache-status by Rasmus Lerdorf,
– OpCacheGUI by Pieter Hordijk,
– opcache-gui by Andrew Collington.
May the Cache be with you.
Stefanos Kofopoulos liked this on Facebook.