--- 9 layers php cache for high performance websites --- The way of optimizing most PHP Websites are pretty simple & don't require any expensive webserver to run heavy load applications.
( quiet a long time since I haven't written anything here, becuz I've just never had the time at all ... )
The first places to look for any optimizations are obvioulsy within the mysql queries & php code : as for year 2008, this blog upon a collocation host, took more than 83 sec to generate a page as 4 users online ..
First step : implement a timer & debug functions ( as registered shutdown functions ) within your code & log them !!
Here is the 9 layers PHP cache I've setup this far :
1 : Mysql results cache & mysql inner cache & mysql indexes ****
2 : Full page html cache expires in future + binded with 304 handler ( with inner codes to invalidate data from separate block suppressed with grep upon cron ) *****
( you won't see them performing better if you put them in ram .. as the page's output will take the more time here .. that's why 304 has to be implemented here )
3 : Opcode cache ( newer php version are faster, indeed )**
4 : JSON serialized data arrays served with 304 headers whetever or not the data has been modified ( upon invalidation ) ***
5 : Array based file cache in Ram ( includes redis, memcache ) ***
6 : Individual static html files cache for individual blocks
7 : 304 headers using browser own cache ****
8 : Reverse-proxy : consider using a cdn is the same effect here
9 : Cdn : cloudflare
Then I'll demystify some legends :
- Well configured apache performs better than NGINX ( AllowOverride Off, logging static files .. )
- Amazon t2.micro instance aren't so expensive after all and are quite fast !