Reputation: 1855
I am using AngularJS 1.3
and I have a backend that supports only HTTP requests. (without WebSockets).
What is the best option for most "real time" data updates?
Right now I am using $interval
and sending http request every second but I am not so satisfied I am always thinking maybe there is a better option.
Thank you !
Upvotes: 0
Views: 65
Reputation: 14053
Based on your description, there's not really an alternative, but you may be able to optimize the behavior based on the characteristics of your data and/or the user interface.
To minimize the resource consumption, for example, pause any requests when the relevant aspects of the interface aren't visible (e.g. in a different "page" or even if the user has switched to a different browser tab).
If the data is high volume but doesn't change frequently, you could set up your server to return a 304 Not Modified
until the data actually changes.
You could also send only diffs instead of the full data set if that results in a significant bandwidth savings.
Upvotes: 2