I have a home page that has several independent dynamic parts. The parts consist of a list of recent news from the company, a site statistics panel, and the online status of certain employees. The recent news changes monthly, site statistics change daily, and online statuses change on a per minute bases. I would like to cache these panels so that the db is not hit on every page load.
Is using ob_start()
then ob_get_contents()
to cache these parts to a file the correct way to do this or is there a better method in PHP5 for doing this?
In asking this question I'm trying to answer these additional questions:
- How can I determine the correct approach for caching this data without doing extensive benchmarking?
- Does it make sense to cache these parts in different files and then join them together per requests or should I re-query the data and cache once per minute?
I'm looking for a rule of thumb for planning pages and for situations where doing testing is not cost effective (The client is not paying enough for it I mean).
Thanks!