I'm trying to output a set of image thumbnails in HTML table. Everything
works fine, except that performance is very poor. If I put all the
thumbnails as regular files in some directory it has expected speed. But
if I'm trying to use script to retrieve thumbnails from their actual
location (which may be database for example) speed drops down
dramatically. And what is even more strange, from apache log I see that
script is terminating very fast, less than 0.5 second for each image
(they are relatively small, ~2K), but browser is spending huge amount of
time "downloading" images two at a time. 

Image retrieving script is very simple:

$expires = 24 * 60 * 60;
$gm_expires = gmdate('D, d M Y H:i:s', time() + $expires);
header("Cache-control: public, max-age=$expires, pre-check=$expires");
header("Expires: $gm_expires GMT");
$filename = DATA_DIR . '/' . $_REQUEST['ID'];
$fp = @fopen($filename, 'r') or die ("Cannot open file $filename");
$story = fread($fp, filesize ($filename));
$packet = new Packet($story);
$content_type = substr($packet->value('IMAGE_FILENAME'), -3);
header("Content-type: image/$content_type");
header("Content-length: ". strlen($packet->value('IMAGE_REGULAR')));
echo $packet->value('IMAGE_THUMBNAIL');

and call for images is made like this:

echo "<a href='$url' target='story'><img src='show_image.php?ID=$id&s=0' width=65 

Does anyone has such a problem before and is there any solution?

Thank you,
Infodesk S.A.
Gustavo Mejia Ricart #70
Santo Domingo, Dominican Republic

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to