Need a solution? Call Us Now!
1800 880 841

PHP Caching - A Great Way To Super Charge Your Server

Drastically reduce your server load by employing PHP caching. PHP caching is easy to set up and pays for the effort many times over with better system response time and less downtime.

To run a high performance PHP/MySQL server, one has to keep a close eye on the server load. A high performance mechanism to drastically reduce loads is caching. A system that effectively employs caching exhibits much higher performance and less downtime. MySQL includes mechanisms for caching via MySQL's Query Cache. At the same time, this caching system does not improve performance if any of the rows in a large table are altered, so there is no 'row level' caching in MySQL, only 'table level' caching.

So how do we deal with this issue? The solution lies in using one of the caching systems available to PHP. One that I have used to great satisfaction is Cache Lite, which, under PHP program control, caches data to hard disk for a period of time as specified by the program.

So lets take a look at Cache Lite and see how it is incorporated into the overall PHP script design. First, search for and download Cache Lite. Then save the files under 'Lite' directory to a subdirectory under your webserver's root (e.g. 'Cache/Lite'). After that, you can refer to the example file in the downloaded documentation (the file is called 'examples'), which provides a working example, and that information is not repeated here.

Here I will concentrate on cases of use. Take a bulletin board, for example. Moderator information is kept in users table, and that table can get large. Normally the moderator information does not change often. In this case, table-level caching available in MySQL does not provide performance improvements when any changes are made in the users table. Instead, a cache can be set up with PHP to cache all the moderator information for say 24 hours.

The above approach works great, but there is a tradeoff. What if a moderator is added or dropped, or some other information related to this moderator is changed. In this case, we have to add PHP code to delete/refresh the cache, or to make the cache timeout reasonable short (say 10 minutes).

Another point to keep in mind is with Linux directory access control, we need to do a 'chmod 777' for the directory that keeps the cache data. This will enable PHP to read/write from/to that directory.

In summary, PHP can easily be supercharged to deliver performance in demanding environments. PHP can also overcome for the current shortcoming of MySQL which is lack of row-level caching.

 
Want to know more?Call 1300 880 841 or click here to contact us.