Page 1 of 1

simple caching script needed

Posted: Sun Jan 04, 2009 10:53 am
by ViserExcizer
Hello, i want to know how to cache a dynamic php page. I've tried many caching scripts, but none of them are working. I must be doing something wrong, but i couldn't figure it out.

I need to cache a php file which has a lot of mysql queries(which is causing an overload on the server) every 5-10 minutes, and output it as a html, in a writable directory, for inclusion. Can anyone help to point me in the right direction, or show me a site or blog that explains this in detail?

Re: simple caching script needed

Posted: Sun Jan 04, 2009 11:38 am
by sergio-pro
Hi,

You can use ob_xx functions for that.

see http://ua.php.net/manual/en/function.ob-start.php

before the script call ob_start(),
after script executed (printed html to output): $html = ob_get_contents();
then save $html to a file and call ob_end_flush();

Re: simple caching script needed

Posted: Sun Jan 04, 2009 11:41 am
by Eran
You should have a look at Zend_Cache, especially on the second chapter: the theory of caching. http://framework.zend.com/manual/en/zend.cache.html