What's with this site! ( http://www.Brothersvarietystore.com)
I have tested the speed at a site, and the page load time was 20.8 seconds! I don't think that is too good as far as speed is concerned.
Here's the specs:
I use a random image php script to fetch the images from a MySQL database on a unix server. This is that code:
Quote:
<?
// Connect to the database
mysql_connect ('localhost', 'user', 'pass') ;
mysql_select_db ('db_name');
// Edit this number to however many links you want displaying
$num_displayed = 1 ;
$category = '5' ;
// Select random rows from the database
$result = mysql_query ("SELECT
products.pid,products.cid,products.title,products. image_url,catalog.name
FROM catalog LEFT JOIN products on products.cid=catalog.cid WHERE
catalog.cid = $category OR catalog.parent = $category ORDER BY RAND()
LIMIT $num_displayed;");
// For all the rows that you selected
while ($row = mysql_fetch_array($result))
{
// Display them to the screen...
echo "<a href=\"http://www.brothersvarietystore.com/apparel/shop/index.php?p=product&id=" . $row["pid"] ."&parent=" . $row["cid"] . "\"> <img src=\"scripts/displaythumb.php?image=" . $row["image_url"] . "\" border=1 alt=\"" . $row["title"] . "\">
<br>
$row[title]
</a>" ;
}
?>
|
Displaythumb.php is the file to re-size the full-size images (dynamically) from another webserver (yes the products are hotlinked) but with LEGAL permission.
Here's the displaythumb.php code:
Quote:
<?
/* ...check size ratio and set appropriate dimensions for the thumbnail */
$src_url = $_GET['image'];
$filetype = substr($src_url,-4);
if($filetype != '.jpg') exit;
$sizelimit = 120;
$size=getimagesize($src_url);
$src_width=$size[0];
$src_height=$size[1];
$ratio=($src_width/$src_height);
if ($ratio >= 1) {
$dest_width=$sizelimit;
$dest_height=($sizelimit/$ratio);
}
elseif ($ratio < 1) {
$dest_height = $sizelimit;
$dest_width=($sizelimit*$ratio);
}
/* ... make the thumbnail and save it to $thumb_dir */
$src_img = imagecreatefromjpeg($src_url);
$dst_img = imagecreatetruecolor($dest_width,$dest_height);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
header("Content-type: image/jpeg");
imagejpeg($dst_img,'',80);
imagedestroy($src_img);
imagedestroy($dst_img);
?>
|
My question is simply this:
How can I clean up the issue here, which is the 20.8 seconds loading time?
Site again... ( Http://www.Brothersvarietystore.com)
Many Thanks in Advance!
-Brian
__________________
Made2Own
|