Easy PHP Caching: Speed-Up Dynamic Content
March 12th, 2009 by MattCaching dynamic content can save a lot of proceesing power, potentially saving a server from total meltdown under extremely high traffic loads. The popular WP Super Cache plugin has demonstrated this, helping blogs on small shared hosts survive the “Digg Effect” longer.
If a script’s output doesn’t change every time a page is loaded, does it need to be processed each time? Probably not. You can cache a page, or a section of a page, for an appropriate amount of time, and serve it up instead.
It’s a lot simpler to implement caching than you would think. It’s just a matter of using output buffering, a little bit of basic file I/O, and watching the server’s timestamp.
PaperMashup.com has a short article on how to apply a basic cache to your scripts.
It’s not a good idea to go away and cache your entire site, you need to think about which pages receive high traffic, and which pages make a number of database requests. Static HTML pages aren’t going to see a benefit from caching and may in fact be served slower due to PHP invoking the request to the cached version.
Twitter
TwitterThe archaic and overpriced SMS system is easily fungible with Instant Messaging and email? Why do people use it so much?
Follow Matt on Twitter