php – Uso setInterval X WebSockets

Question:

I'm developing a PHP application with AngularJS, this application has a messaging system. I only need to check the message quantity at least every 2 min. My doubt would be, would the use of setInterval be recommended in this case, or would the creation of a Socket be better? Since the update is just showing the user the amount of unread messages and this every 2 min.

Answer:

In your case I recommend setInterval, knowing that the update interval is fixed, Socket will keep an open connection on your server, updating all the time, so I don't see the need for its use!

Scroll to Top