【发布时间】:2011-11-08 02:41:35
【问题描述】:
我们正在尝试创建一个新网站,当我在浏览器上写下我网站的链接时 例如:www.mywebsite.com,等待时间有点长。
我看到一些网站的等待时间比我的要短,有什么方法可以减少等待时间,我们也在为网站使用 memcached 吗?
PS: idk 到底是怎么调用的,但我用 firebug 看到它,它说等待时间。
谢谢。
已编辑
这是我用来从数据库中获取数据的代码:
function f3($id = '') {
$id = mysql_real_escape_string ($id);
$sql = 'SELECT id,post_title,post_content,post_date,post_status,term_taxonomy_id,object_id FROM wp_posts, wp_term_relationships WHERE term_taxonomy_id = 60 AND post_status = "publish" AND wp_term_relationships.object_id = id ORDER BY post_date DESC LIMIT 1 OFFSET 2';
$res = mysql_query($sql) or die (mysql_error());
if (mysql_num_rows($res) !=0):
$row = mysql_fetch_assoc($res);
$mycontent = $row['post_content'];
$mycontent = strip_tags($mycontent);
$mycontent = substr($mycontent,0,150);
$mycontent = preg_replace("/\[caption.*\[\/caption\]/", '', $mycontent);
$title = AvinD($row['post_title']);
$old_date = $row['post_date']; // returns Saturday, January 30 10 02:06:34
$old_date_timestamp = strtotime($old_date);
$new_date = date('d.m.Y H:i', $old_date_timestamp);
$first_img = '';
$my1content = AvinD($row['post_content']);
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $my1content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "/img/default.png";
}
echo '
'.$new_date.'
<a href="single.php?id='.$row['id'].'"> '.$title.' </a> </div>
<a href="single.php?id='.$row['id'].'"> <img src="timthumb.php?src='.$first_img.'&h=107&w=190amp;zc=1" alt="" /> </a> </div>
'.$mycontent.'
'; //echo
else:
echo 'Page dont exist';
endif;
} // end
【问题讨论】:
-
您是否正在加载任何外部资源? (脚本、css、图像等)如果是,则可能是外部资源的主机运行缓慢,而不是您的服务器。
-
对于一般性建议,请查看Page Speed 和YSlow。
-
类比:有的车以 100 公里/小时的速度加速 4 秒,有的车加速到 10 秒。如果不知道这些车在比赛中使用的具体情况,你怎么能解释这一点。
-
最后的评论很好。我想知道女巫因素使我的网站增加或减少等待时间因素