I have an issue on a HTML5 web app where I have repetitive data updates via an ajax query every two seconds. The first two or three go through at 175ms, but after this, they slow down to 500ms, from then on. The hosting company swears that it is not them. I did a simple test - see test scripts below. It is not my app as this test script has the same results. My question is: Is this the hosting service throttling thinking it is a DDoS attack, or is there something I can do to stop this throttling and slowing down the ajax queries?
The index file:
<!DOCTYPE html>
<html>
<head>
<script src="jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
var count = 0;
var my_timer = setInterval(function(){
$.ajax({url: "test.php", success: function(result){
$("#div1").html(result);
}});
count = count + 1;
if(count == 10) clearInterval(my_timer);
},2000);
});
});
</script>
</head>
<body>
<div id="div1">Let jQuery AJAX Change This Text</div>
<br>
<button>Get External Content</button>
</body>
</html>
The php file:
<?php
echo date('h:i:s');
?>
[SOLVED] After much research into this issue. I think I have finally figured it out, or at least found a workaround. Apparently CentOS and/or Plesk Php was blocking. They way I have resolved the issue was to re-image the server on openSUSE 13.1. With this OS the Ajax queries seem to work as they should. This is just a guess, but it looks like the PHP and or the CentOS software update mechanism also has bugs in it. The updates seem to not work well and create issues. So for now I won't fix what is not broken.
Thank you for the input the commentators made, as it did point me in the right direction.