我調用AJAX來檢查數據庫是否每3或10秒鐘有一個新的通知,同時查詢來自4個不同的瀏覽器。但是在循環100+後的某個時間點,服務器返回錯誤508(循環檢測)。這只是簡單的網站,所以我不認爲我需要VPS服務器。重複性檢查觸發器錯誤508(循環檢測)
我在SELECT中添加了時間戳作爲查詢區分符,放置了unset,flush,mysqli_free_result,pause,mysqli_kill,mysqli_close,但仍然出現錯誤。入場流程達到20/20。
腳本
var counter = 1;
var notiftimer;
$(document).ready(function() {
ajax_loadnotifs();
});
function ajax_loadnotifs() {
$.ajax({
type: "post",
url: "service.php",
dataType: "json",
data: { action:'loadnotifs' },
success: function(data, textStatus, jqXHR){
$("div").append($("<p>").text(counter++ + ": succeeded"));
notiftimer = setTimeout(function() {
ajax_loadnotifs();
}, 3000);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR.responseText);
}
});
}
service.php
$link = mysqli_connect('localhost', 'root', 'root', 'testdb');
$notifs = array();
$query = "SELECT id, message FROM notifs LIMIT 20";
if (!$temp_notifs = mysqli_query($link, $query)) {
die(json_encode(array("errmsg" => "Selecting notifs.")));
}
while($notif = mysqli_fetch_assoc($temp_notifs)) {
$notifs[] = $notif;
}
mysqli_close($link);
echo json_encode($notifs);
的cPanel - 資源使用概述
當Entry Entry命中20/20時,我得到錯誤508.如何維護低服務器輸入過程? (測試了4級不同的瀏覽器,運行它們,直到環100+在共享主機本地計算機上沒有問題)
如果你可以添加更多的代碼,它將幫助我們弄清楚發生了什麼。表面上,每三分鐘四次觸發腳本不應超出您的輸入過程限制。 –
@Jeaf Gilbert,當發生這種情況時,請在瀏覽器中打開網絡選項卡,並向我們顯示此類失敗請求的響應標頭。然後我們將看到哪個程序返回這個錯誤。它可以是Web服務器,PHP或一些代理。 –
@ i-man更新,請看看。 –