Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Old 03-22-2006, 01:11 AM Slow Loading?
Brian07002's Avatar
Defies a Status

Posts: 2,139
Name: ...
Location: ...
Trades: 0
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

Please login or register to view this content. Registration is FREE
Brian07002 is online now
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Slow Loading?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09539 seconds with 12 queries