I have an iPhone app that grabs information from different sources in XML format. For example i have a UITableView displaying information, in xml format after being parsed, from an url like this one http://mysite.com/posts.php?top=100 -> returns posts information like this
<postsList><post><title>test1</title><pubDate>..</pubdate></item><post><title>test1</title><pubDate>..</pubdate></item></postsList>
so i have one request only for showing the table with posts. when i click on a cell i have to make three calls to three different sources to gather the data i want to show in the details of the cell.
I was thinking to write some ASP.NET C# webservices that, when called, gather all the info i need and return a single response(so i make one request) when i show the initial UITableView.
The xml response will have 10-15kb max with all the data included. From my experience network access(wireless or 3g) is expensive on the iphone from the performance point of view and if possible i would like to avoid it if it’s not necessary.
So the question is: is it a good idea to get as much data as possible from a single request or is it better to make requests only when data is needed(in this case when a cell is displayed)?
If you’re on a slow cellular connection, the latency will hurt you more than the limited bandwidth. This means that setting up a connection will take a lot of time because of the latency.
If you’re talking about 10-15 kb, I would get all the data at once (of course, you should do that asynchronously)
Let’s say you’re on a GPRS connection, which is 384kbps (in our country at least). The latency is in the order of 500ms, so setting up a HTTP connection could take about 1 second (best case). Transfer speed is about 40KB/s.
Using a single download:
Using 10 small downloads:
This is not a scientific test, but it simply shows how you should tackle these kind of decisions.