Daily hits

475/5000

I would like to understand exactly when a hit is counted.
If the page is refreshed, does it generate hits?
Does an ajax call generate hits?
Does writing in an archive (fwrite) generate hits?
Does reading an archive (fread, file()…) generate hits?

For example, if I create a javascript settimout that makes an ajax call every 5 seconds to read an archive, will this generate hits?

I am new to the web pages in real time and if it is not making ajax calls from time to time to read files I don’t know how to do it, any recommendations?

https://infinityfree.net/support/hits-limit/

I had already read this post.
I am new to this whole topic and it has not been clear to me, can you answer my questions please? Thanks in advance

1 Like

Yes.

Yes.

Yes.

Yes.

Yes. And to do that every 5 seconds, you need to use setInterval function for it, because setTimeout is just for executing it once after 5 minutes.
So the conclusion is that all things loaded on InfinityFree (whether they are PHP scripts, HTML, CSS or JavaScript) can use daily hits.

1 Like

okay. Thank you. Then I will explain my problem:
I am making a website that when a user does something, information is saved in a file. This file is constantly being read every 3 seconds (with a Settimout that calls itself with an ajax call) in order to show the information to all users. I guess this is why the page generates many hits. So I understand that doing something like that is unfeasible. What would be the correct way to do this?

1 Like

@Ergastolator1 is mostly correct, except for the PHP file changes (fread, fwrite, fopen, etc.). Calling a PHP script from the browser generates 1 hit, regardless of how many files the PHP script touches. The only way a PHP script could generate more hits is if it does a HTTP call to another page on your site.

Hits are counted on the web server (i.e. Apache/NGINX) level, not on the PHP level.

This sounds quite similar in setup to how a live chat script works, by constantly polling the server for new messages. Chat scripts generate excessive hits and server load, which is why they are not allowed to begin with. Your particular use case is not explicitly prohibited, but if you run into limits because of how your website works, you can safely assume that’s intentional.

The “right” way to do this would be to use websockets. With websockets, you can setup a continuous connection with the server so the server can send messages to the client (which is not possible with HTTP). But our hosting doesn’t support it, and I don’t know whether there is any web hosting provider who does. So you may need your own server for this.

Alternatively, you could use a service like Pusher to push messages to visitor browsers.

1 Like

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