ibrow

ibrow blog

news, views and portfolio

Really Simple Content Caching (PHP)

October 2nd, 2007

I have built a (as the title suggests) really simple content caching class in PHP. I had a particular itch I wished to scratch today, and the ReallySimpleContentCaching class is the result.

I am currently working on a project that has a Flash front end that communicates with PHP in the backend via XML. Based on what is passed in the XML, PHP goes off interrogates a database, generated an XML reply. The building of this XML reply can be quite complicated and make a lot of DB calls. Also, it might be high load and therefore impact on performance.

The solution is caching.

There are a lot of caching methods out there, Smarty has excellent built in caching, and there is PHP Output Buffering. But my needs were to small to warrant Smarty and I was not caching the output, So I built my own little class.

You can see an example of it in action here. Note: This is a very boring page!

You can also download the source code for the ReallySimpleContentCaching class and associated files here (zip file).

I have tried to include as much commenting as possible so you can see what I did. (As ever) I will try to get around to writing a brief tutorial on this if I have time.

But otherwise, download, play with it, improve it and enjoy.

Leave a Reply

You must be logged in to post a comment.

ibrow.com


tel: 020 7183 2328

BarCamp Berlin 3