I’m writing a web application (HTML/CSS/JS frontend, C# backend) where the users are expected to be on the same page for a while (usually longer than 10 minutes). I would like to periodically check the server to see if the user’s session has expired. Is there any disadvantage to using setInterval with an interval of say, 2 – 5 minutes, to make an AJAX request to the server?
I’m writing a web application (HTML/CSS/JS frontend, C# backend) where the users are expected
Share
No, there is no disadvantage. However, the timer isn’t the most accurate. See also: Will setInterval drift? This may not matter to you, as it is a bigger problem for timers fired rapidly. Plus, it doesn’t soundl ike exact timing is a problem for you either.