加载图像花费了太多时间


Loading of Images is taking too much time

这是我从数据库加载index.php页面中图像的代码。

<div id=images>
    <h1><?php echo $row['title']; ?></h1> //Title coming from database table
    <img src="<?php echo $row['image']; ?>"> //Image url coming from database table
    <hr/>
</div>

我创建了一个外部css文件style.css,如下所示:

#images img {
    width:100%;
}

我在这个页面上总共有20-25个图像(每个大约30-35KB),每个图像的平均加载时间是1秒,这导致整个网页在大约25-30秒内打开。

同样的东西正在我的竞争对手的一个网站上使用,具有相同数量的图像(每个大约超过100KB),每个图像的加载时间大约为0.13秒。

根据我的分析,问题只是图像的代码。请帮我提供你宝贵的答案。

1)可能您的服务器上传速度太慢
2) 压缩图像

尝试使用以下代码来使用带有deflate编码内容的网页:

<?php 
    if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) 
        ob_start("ob_gzhandler"); 
    else ob_start(); 
?>

您可以使用缓存以下是链接Php 缓存