Implementing Data Caching in your Windows Phone app

Generally web services have restriction laid upon them like number of API calls you can make per hour or day. It is important in such situations to cache data on the user device. If you are creating an app with restrictions like Flickr or Twitter API this method might be useful.

Implementing Data Caching in your Windows Phone app

Here is a  sample restriction text pulled from a web service.

“You must not create any application which polls the API more than four times in a two second period or more than 200 times in one hour. Caching is permitted and encouraged. The API has been designed so that most queries can be satisfied without the need to call methods from within a loop. For this reason the practice is strongly discouraged. If you do call the API from within a loop it must incorporate a delay so that the above limits are not exceeded and it must be designed to terminate after a finite number of iterations under all conditions.”

So how to deal with it, you will have to extensively cache data. One option is to use AGFx with MVVM (or MVVM lite framework). The other option which I used was to store data in the local storage and use that for every access.

Here is a link which which explains everything

There are a few advantages to this :

  1. There are no queries to the web service, hence the app can remain within the limit
  2. The apps runs super fast, pages will open up instantly since all the data is local. But the user is never aware. You can also provide a pseudo offline mode to users.
  3. You won’t have unreliable crashes due to loss of internet connectivity ( again you can provide offline mode). Always Online might be an issue in many countries where 2G connections are still in use. So this is of great help.

Hope this has helped in your decision to use Local storage in your app.