Use cases for APC's opcode cache


I’ve been exploring ways of speeding up way website and I’ve implemented browser caching, a CDN, and have Stash (a caching library) to cache database queries when they’re slow. Implementing an opcode cache sounds like another great way to speed up my site since the PHP code won’t have to be re-compiled on each request.

However, I don’t see exactly how this type of caching should be used in practice. What PHP code am I sending to this cache? For example, my header and footer don’t change on each request, nor does my config file. Would these specifically go in an opcode cache such as APC or could they go in a cache such as Memcache or a filesystem cache? Or, does it matter which type of cache it goes to?


Hi kreut,

APC or rather Zend OpCache are extensions that run in the background. You don’t need to program anything to use them. It is mainly a setup thing. PHP5.5+ even has OpCache included, so if you are using PHP5.5 or higher (which you should be), you are more than likely already running OpCache.

Here is a pretty good article about it.


Have you explored using a static cache?

Hi Scott,

Thanks for the link! So, what you’re saying is that if I’m using PHP 5.6 then OpCache is running already? Is there anyway to see what code is being cached by this process?


Are you referring to caching my static assets?

No, I’m referring to statically caching whole pages with varnish or akamai. One of the most effective ways to speed up a site is to never hit the server using a static cache.

Yes. My host actually already has Varnish in place. Thanks!

You mean something like these solutions?



Super helpful! Thanks for both of your links.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.