What is best practise for polling server with JavaScript for application that needs to refresh data very rapidly? I'm using jQuery for front-end and Java Spring Framework for backend.
Example of refreshed data could be list of items that are getting updated very rapidly (every 1 second).
You may want to use jQuery's Ajax functions to poll the server every second or so. Then the server can respond with instructions to the browser in near real-time.
You can also consider long polling instead of the above, to reduce the latency without increasing the frequency of the polls.
Quoting Comet Daily: The Long-Polling Technique:
In addition to the above, I also suggest that you check out the accepted answer to the following Stack Overflow post for a detailed description of the long polling technique:
I second Daniel's suggestion to use long-poll or push. Check out
They have a page explaining how to get that work with Spring:
As of 2018 you should use the fetch function with promise syntax: