I have some query. First of all let’s have an iPhone application flow which a normal application has. ( Content based application )
- Application launches & checks for the network availability
- If network is available – iPhone downloads the data using web services or APIs
- We can store these response ( web service response / api response ) into a *.plist file.
-
When we need to update the data, again web service is called & again entire data is stored *.plist file.
-
Now, assume that – I have a table ‘eBooks’ on Server & It has more than 500 entries.
- Calling a API/web service will give response of 500 records.
- OK – first time it is ok to wait for all response ( we might use LIBXML2 for chunks )
- But what if when we frequently download this using web service.
Here there are two disadvantages
- Wifi unnecessary usage
- iPhone CPU overhead
- Server CPU overhead.
Are you getting me?
Assume that there is no change on server why iPhone need to call API again. Means there are no change in entries & entries are 500 as it is then why to download it again?
Let me clarify again – the problem.
Assume that
- an application has a Server + database = Customers ( 500 records currently )
- there are 5 iPhone which retrieves this data
- all iPhones have downloaded 500 records offline
- Now, server has added a new record 501
- iPhone must download only 1 record not 501 at all.
How is that possible?
You could add a timestamp to each of the entries. This timestamp is updated every time a change, addition or deletion is made on the server side.
When doing a query, you supply a field indicating the latest timestamp known to the client. For the first query, this would be something like Epoch. For subsequent queries it would be the last known update.
The server would then have to filter the entries, so it only returns those entries that have changed since the provided timestamp.