Nginx & PHP caching: fastcgi_cache, proxy_cache, APC or memcached or combo

cachefastcgimemcachednginx

We have webservers running nginx 7.65 along with fastcgi PHP5 and are looking into caching possibilities to speed up content delivery and lower system loads. The servers run different (custom) applications.

There are so much options for caching I am not sure what would be a sane setup.
There is memcached, APC, Nginx' fastcgi_cache, proxy_cache….

I know memcached has the distributed ability as bonus but we do not need it at this point.
In my experience memcached performs slower than APC if installed on the same machine as it is serving for, but this was some time ago.

I am not familiar with the Nginx fastcgi_cache or even the regular proxy_cache module.
Is it comparable or is it something completely different?

What would be a good, sane caching method for Nginx w. FastCGI PHP5?

Best Answer

If your box can handle the entire cache on its own, memcache will only slow you down. APC is shared memory. Used right it will blow away memcached. Nginx fast cgi cache will make all dynamic php pages scream. Even if you set the cache to just 10 seconds, this makes it such that that max hit rate to any given php page will be once every 10 seconds. Makes it impossible to crash a page with load. I run a bunch of websites on a single small box that gets millions of people per month. All you need is nginx caching and APC at this point.

Memcache comes into the picture only when you have to scale your cache beyond a single box.