Cache Management in Php:

Zend Framework has some classes to manage cache through PHP, however, based in my personal experience with cache managers, it is not the best option if you want to speed-up your web sites.

I'm using XCache ( It has many advantages comparing with others. Other good cache is Memcache, but I read that is designed mainly to be used with multiple servers. So, for simple tasks is not the ideal. Additionally XCache translate your codes to opcode improving the access speed. I made my self some benchmarks using the same code and task (to load an html page and display it). I run 1000 times (with ab).

My results were:

With-out any "improvement": 9.18 seconds. (in my small server, so it is not so fast).

(ZF=Zend Framework)
1. Using ZF cache with backend FILE: 44.23 seconds
2. Using ZF cache with backend FILE and using Xcache for opcoding: 14.97 seconds
3. Using ZF cache with backend Xcache (instead of memcache) ***: 9.86 seconds
4. Using only Xcache for opcoding (without any modification to the original file): 9.31 seconds
5. Using Xcache wih the Cache "module" I made: 8.053 seconds
6. Using Xcache directly: 6.21 seconds

*** I downloaded an Interface to use XCache with ZF.

This is taking into consideration that was only a simple task and that the performance may change with a more complex system.

By the way, Xcache don't need to recompile php or apache. It can be used as a module and is very easy to install.

Using XCache directly was the fastest, but it may not be so clean once it is used inside your codes. There is other way, that is, to cache all the pages, adding some code at the header and the footer of each page, or doing it with "includes", but it will not use memory efficiently. I personally don't recommend it for new systems. For old systems, is the best way, because you don't need to modify too much, and increasing the server physical memory, can improve a lot.

I also installed XDebug, a very good tool for development that can show you where your codes can be improved identifying bottlenecks. If you have time, give it a try... I think it is really useful.$ ls

drwxr-xr-x lepe  4.0K 2019-04-30 04:07:16 .
drwxr-xr-x lepe  4.0K 2019-04-30 04:07:28 ..
-rw-r--r-- lepe 2.8KB 2019-04-30 04:07:16 cache_management_in_php.html
-rw-r--r-- lepe 5.3KB 2019-04-30 04:07:16 hide_your_email_from_spambots.html
-rw-r--r-- lepe 3.3KB 2019-04-30 04:07:16 my_linux.html
-rw-r--r-- lepe 8.3KB 2019-04-30 04:07:16 simple_intranet_dns_server_in_linux.html$