Home » Php » caching – PHP APC Cache, does it work out of the box?

caching – PHP APC Cache, does it work out of the box?

Posted by: admin July 12, 2020 Leave a comment

Questions:

So this is whats bothering me. I just installed APC cache and Im testing it.
When using APC Admin interface, in apc.php file, I can see all the info about APC etc.
When I go to System Cache Entries I can see that every script i invoke gets written there.

So does this means that APC Cache works out of the box? I can just install APC cache and it already speeds up my application by caching scripts? And if I want I can then cache variables to make it even faster?

Hope you get the question, its probably simple to someone with more experience with APC.

Its I know i can add some variables to cache, and then get them out and that will speed up my app. But is it true, that APC will speed up the app and cache scripts all by him self?
And is there any good documentation where I could learn more about APC?

How to&Answers:

Yeah, APC “just works”. Anyone running PHP in production without APC/(other opcodecache) is missing out on the easiest performance improvement they can readily achieve.

A few caveats though.

If you are in development, you can still run APC, however, you probably want to enable stat calls. This means that APC will check the last modified of your files.

apc.stat = [1|0]

So if you don’t have stat calls enabled, and you change a file and APC has already cached it, then it won’t observe your changes, and you will continue using the cached opcode.

As you have mentioned, APC isn’t just for opcode caching, it is also useful for user space caching. You have your system cache and your user cache.

You can store things against your user cache by just performing something like:

apc_store("fooKey", "barValue");