I'm building an interactive page where a chatbox and a list of items appear.
I intend to update both of them every 30 seconds using JQUERY's .post() function, but I realize many users keep webpages opened in tabs 24 hours a day, creating a heavy load on the server.
In order to prevent this and to optimize my ressources, I would like the database polling to be executed every 30 seconds ONLY if the user is active on the page; in the passive cases, I would like a 5 minutes polling.
How can I achieve this? (I'm using PHP and MYSQL)