Question about hits limit

If I use AJAX to automatically update the database, it will count as a hit? I coded like this…

<script>
  function getUserStatus() {
    jQuery.ajax({
      url: 'ajax/get_user_data.php',
      success: function(result) {
        jQuery('#data_grid').html(result);
      }
    });
  }
  setInterval(function() {
    getUserStatus();
  }, 1000);
</script>

It calls ajax/get_user_data.php pages in every 1 min. it will count as a hit? Please help me as soon as possible. Thank you.

Depending on what is inside get_user_data.php, the number of hits could be much higher than that

6 Likes

Every time a URL is called, it creates a hit. So yes, that code will create one hit a minute, if not more (It would cause more if the get_user_data.php calls other files when it is run.

5 Likes

get_user_data.php, page contains only mysqli queries

Then it will use 1 hit every time it is loaded

4 Likes

Then hits limits are very bad…

What do you mean by that? The number of people that hit this limit is pretty low, as this limit is really high, especially for free.

If you need this limit to be higher, please upgrade to premium hosting. Using AJAX is not really a good idea here for that very reason anyways.

5 Likes

It will be every 1 second since OP set the interval to be every 1000 milliseconds

The limits are not bad. 50,000 hits for a free service is awesome. However, if you still need more, I suggest to

8 Likes

Correction: every second, not every minute.

The second parameter of setInterval takes a time interval in milliseconds. You set it to 1000 milliseconds, which is one second.

If you only want it to trigger once per minute, you need to set it to 60000 instead.

Our hits limit is very reasonable. But if you write code that’s continuously hammering the server in the background because of a coding error, then you’ll exhaust your account’s limits very quickly.

To be very clear: the “call other files” part only applies if you use something like file_get_contents to trigger other URLs on your site. Calling other code by using things like require and include doesn’t generate additional hits usage.

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.