simple caching script needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ViserExcizer
Forum Newbie
Posts: 24
Joined: Tue Nov 25, 2008 1:17 pm

simple caching script needed

Post 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?
User avatar
sergio-pro
Forum Commoner
Posts: 88
Joined: Sat Dec 27, 2008 12:26 pm

Re: simple caching script needed

Post 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();
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: simple caching script needed

Post 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
Post Reply