Every web developer I know wants to find ways to speed up their application. In fact, some go so far as to worry if double-quotes are slower that single quotes overall - more often than not, it just doesn't matter. Instead, they should be looking to other things, things like the applications are are running things behind the scenes. Jo Brunner knows this, which is why this new post has been made on the ThinkPHP blog today - a look at caching content to help de-stress your server.
The method I would like to describe is based on the webserver lighttpd. Lighttpd is a single process webserver written for high traffic sites. It supports fast-cgi out of the box which makes it ideal for hosting PHP applications.
n the scripting world, a common way to optimize the response time of an application is often as follows: the application by itself saves every page result (or fragments) into a cache file before delivering. The next time a routine has to check whether it could output cached content or not. The cache has to be rebuild periodicaly or when the application updates some data entries - it deletes cache files - and generates them again.
But there is a bottleneck: every time the webserver gets a request it has to start the application - even there are no changes made on the data in the background. t would be nice if cached files could delivered as static content. But the question is: how can a webserver decide if a cache file is outdated without involving the application!
So Jo proposes an alternate solution - using a combination of lighttpd, MySQL, and PHP as fast-cgi to lighten the load. Code/configuration examples are included, and all of the complimentary modules needed are linked to as well. There's even a sample PHP application to help illustrate the point.