Can Ajax keep reloading/executing for multiple days without true refresh?
Ok, here's the scenario. I'm wanting to have a page open on a client for a long, long time. Say... one week or one month even. I've got Ajax sending requests continuously, sending a new request whenever data is received or whenever the initial request times out.
Code essentially is:
- function doTempPoll() {
- $.get("api/feel/ac/currentTemp.php", function(data){
- apartmentTemp.refresh(data);
- doTempPoll();
- });
- }
- doTempPoll();
and on the server side, the server only sends data when something changes (in this case, the internal temperature). The PHP code is:
- //First, the last known temperature is fetched from a DB, and put into $oldTemp
- $i = 1;
- while ($i <= 10){
-
- $temp = getTemp();
- if ($oldTemp == $temp){
- sleep(5);
- $i++;
- } else {
- $con->query("UPDATE deviceStatus SET statusValue=$temp WHERE id=1");
- $i = 15;
- }
- }
- echo $temp;
As you can see, the server will hold the connection open until 50 seconds, then send the current temperature. If the temp changes during the 50 seconds though, it will send the update almost immediately.
I'm having that Ajax function run over and over and over.
Seems like it ran for a few hours fine overnight... probably about 12 hours if I had to guess... and then stopped updating. The jQuery AJAX call stopped working, as the script never spawned the Ajax PHP call which updates the database, because I saw the database had old data. That means it isn't an issue of the new data not getting added to the DOM, but rather the Ajax call itself was never kicked off.
Is there a maximum number of times an Ajax request will get sent, or a period of time after which the page just stops sending that data? Possibly I just need to set a meta refresh value for, say, 8 hours?
Host is an Ubuntu client running Chromium, if that matters.