I'm pretty new to server-side web development. What I want to do is to dynamically create a web page with php (no problem for that), but in this page there is an image refresh timer that update an image through AJAX.
My goal is to dynamically modify (server-side) the refresh rate written in the generated html page based on the current request rate. In other words, if there is only one client that requests refreshes, I want it to refresh once per second. But if there are two clients, I want them to refresh less often, and so, and so (it is a local application, so I don't expect a lot of clients).
I hope I can do that with php. I don't want to overload the server CPU with the computing of this rate. I would like to be able to get it quite easily.
My server uses Apache on Linux.
Someone has an idea? A suggestion? Thanks in advance!
EDIT 1: Maybe I could log a "hit" each time a request is done? But I read that putenv()
will write environment var that will be valid only during the execution of the script...?