I'd definitivly suggest you NOT to use this database-pointer approach! Instead of simply sending that .png-header once you could store the image in a physical file by using an unique ID based on the functions arguments. Later on just check if a file with this ID exists and return its URL instead of calling that function again.
I have recently written such a script (to be used as smarty-plugin) tell me if you want to have a look at it. -----Ursprüngliche Nachricht----- Von: Ashley M. Kirchner [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 31. Dezember 2003 11:04 An: [EMAIL PROTECTED] Betreff: [PHP] Help with PNG creation script The attached text file contains a script that I've gotten from a web site and that I've been using for a while now to generate on the fly PNG headers. There can be several headers on one page, spanning several days worth of articles. The script works, except it's a huge overhead because it generates each header every time it gets displayed. What I'd like to do is amend the script to where it will creates a physical PNG file on the server, so that the next time it's called, it will check its "cache" first to see if that particular header already exists before creating another. Basically something to the tune of: a web page calls the script: script checks internal cache for that header if header doesn't exist create header -> save in cache (disk based?) endif serve header from cache end routine I don't know if it makes sense to incorporate this with an MySQL database which contains pointers to the physical files on disk. I don't know if that will speed up the searching for a particular header (searching the DB, as opposed to scanning the disk directory.) The only thing I can think of is to have a database with a table that contains both article dates as well as the pointer, so the search only has to go through a small set of records, as opposed to the whole DB, but is it really worth it? Now, somewhere in there, it also needs to scan the cache for old headers that are no longer needed, based on a time frame that I set (maybe 14 days? maybe 30 days? I haven't decided yet.) Again, maybe using a DB is worth it so one can simply delete all the pointers and physical files confirming to a specific range search in the DB? Right now, I just want the thing to cut down on CPU usage because it's generating those headers every time a page gets called. Not good. -- W | I haven't lost my mind; it's backed up on tape somewhere. +-------------------------------------------------------------------- Ashley M. Kirchner <mailto:[EMAIL PROTECTED]> . 303.442.6410 x130 IT Director / SysAdmin / WebSmith . 800.441.3873 x130 Photo Craft Laboratories, Inc. . 3550 Arapahoe Ave. #6 http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php