Most mobile applications communicate with the internet. Some draw large amounts of their content from a stream, e.g. The Daily. Games communicate scores, twitter and facebook make API calls to pull your personalized information. It is hard to find a complex, compelling application that does not send HTTP requests.
Developers need to be conscious of how they make requests in order to minimize the impact on the device. Using the antenna consumes battery. Data transfers slower over cell towers than a broadband internet connection. Users are charged for transferring data. In this post I want to analyze how formatting the transferred data can influence performance.
I am currently working on a content-driven mobile application that needs to pull a lot of information across the network. One API request transferred over 1MB of XML. Through a little bit of research, we found that the service had the ability to return JSON instead. By switching to using JSON, the same request was under 512KB. We obtained the same information for half of the strain on the user’s battery. Not every request will see such dramatic differences between XML and JSON, but JSON is a very succinct encoding for data. Whenever possible, seek to find ways to decrease the size of HTTP requests. Your users will experience less latency, longer battery lives, and be charged less; all of which create happier users.


One Comment
We used this idea on SideReel’s iOS application.
In conjunction with the to_api gem and aggressive device-side caching.