URLCache store data

Can I store and load data from url request after loading app and turning off network connection in url cache and how to implement it?

Hi @michael_nechaev,
yes you can. There are a couple of options

  1. When you want to fetch data from a URL, look in a folder you use as cache and if you have this resource, return it from the cache otherwise get it from the server and save it to the folder. (This is not a very elegant solution) BUT this works for cases where you want to download data only once.

  2. Save the resources to the folder like in #1, and if there is no connection, then get the resource from the folder, but if you are connected, fetch it from the remote server. This is also not very elegant because it will download data everytime and update

  3. Use a NSCache or Cache, this allows you to also set the lifetime of the data and manages the connectivity for you

  4. Use 3rd Party libraries that manage the caching for you

Hope you find the one that works for you,



This topic was automatically closed after 166 days. New replies are no longer allowed.