每秒请求一个php脚本会对服务器造成太大压力吗?
|
我正在尝试创建一个简单的脚本,以便使用jQuery和PHP从mysql获取通知(我的代码如下)。目前,jquery每秒获取一次loadmore.php并更新包含它的div。我只是想知道,如果站点流量很大,这是否会对服务器造成太大压力?
源代码:
index.php-
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />
<title>Untitled Document</title>
<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js\"></script>
<script type=\"text/javascript\">
var auto_refresh = setInterval(
function ()
{
$(\'#notifications\').load(\'loadmore.php\');
}, 1000); // refresh every 10000 milliseconds
</script>
<body>
<div id=\"notifications\"> </div>
</body>
</html>
loadmore.php-
<?php
include(\'config.php\');
?>
<?php
$sql=mysql_query(\"select * from updates ORDER BY item_id DESC LIMIT 9\");
while($row=mysql_fetch_array($sql))
{
$msg_id=$row[\'item_id\'];
$message=$row[\'item_content\'];
?>
<?php echo $message; ?><br />
<?php } ?>
没有找到相关结果
已邀请:
5 个回复
涸坍饺
铰齐插
茬贺努充尽
蔬谢窗港
膝垫富顷