Page 2 of 2

Posted: Fri Jun 16, 2006 10:28 pm
by tecktalkcm0391
How would I do dynamic/processing caching, cause I have a page that is included on every page of my website that does 3 querys to my database and I don't want to do them if it doesn't need to because most of the time the data won't change, unless the user's points goes up.

Posted: Sat Jun 17, 2006 12:21 am
by Todd_Z
cache folder of files?

specify the length that the cache is valid for, then if the filemtime() is within that limit, include the cached file, instead of the php file with the queries.

Posted: Sat Jun 17, 2006 4:11 am
by bokehman
tecktalkcm0391 wrote:I have a page that is included on every page of my website that does 3 querys to my database
MySQL does its own caching. All results are cached so that repeat queries are near instaneneous. The cache is store until the table is updated somehow (through INSERT, UPDATE or DELETE).

Posted: Sat Jun 17, 2006 10:15 am
by tecktalkcm0391
OK, good, I didn't know that.

Posted: Sat Jun 17, 2006 1:05 pm
by bdlang
I'm not clear on the cache process (I've not been one to utilize caching in my applications to this point, since most of them are backends for company databases). Is the assertion that dynamic content scripts, i.e. one that pulls data down from a (or many) SELECT statements should not bother with a generalized cache mechanism because MySQL caches the SELECT output? That the cache should be for static content only?

Posted: Sun Jun 18, 2006 12:27 am
by tecktalkcm0391
I just found this, and can't I just use:

Code: Select all

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Data passata
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                                                        // sempre modificato
   header("Cache-Control: store, cache");  // HTTP/1.1
   header("Cache-Control: post-check=1 pre-check=1", true);
   header("Pragma:cache");                          // HTTP/1.0
To make it cache the page that is sent to a user. (Browser Caching)

Posted: Sun Jun 18, 2006 1:21 am
by John Cartwright
bdlang wrote:I'm not clear on the cache process (I've not been one to utilize caching in my applications to this point, since most of them are backends for company databases). Is the assertion that dynamic content scripts, i.e. one that pulls data down from a (or many) SELECT statements should not bother with a generalized cache mechanism because MySQL caches the SELECT output? That the cache should be for static content only?
Let me give you an example, I had a spider that would run once a day to check for new content throughout several major site networks, this collected a massive amount of information and page loads were getting to a couple seconds (which sucks). Instead of pulling up a massive list of datum dynamically, I would cache the data once per day (each time the spider ran).

There are many ways to deal with the logic behind caching, be it a timeframe or logical.. but caching is not limited to static content at all. By eliminating the need to re-run processes that consume processor cycles, caching become very important when there is a need for high performance.