I have a web application to be run on mobile phones that when open continuously generates data (a few kilobytes every few seconds or every few minutes depending on settings) and needs to push it to a server in real time. No data is ever sent from the server to the browser.
My main concern is to make this submission battery efficient, a few seconds of delay is totally fine.
I envisaged two solutions:
- Periodically do a POST to the server with the data (to avoid having a permanent connection to maintain)
- Have an open websocket and periodically send messages (to avoid the weight of an http request)
Which one is the most efficient for the battery? Are there other strategies that I am missing?
Actually my app will be hosted on heroku, which does not supports websockets yet, resulting in long polling, thus for the moment I'll assume it is better to POST on demand, but I am wondering if it could be an option in the future (or maybe this assumption is wrong).