Rest API and caching data

Architecturerest

I have developed an application where you should be able to browse products catalog(READ ONLY) even network access is down no wifi or 3g/lte etc. Clients(windows,ios,android etc) consume the rest api. So far There is a REST api that grabs parts like categories with products and other api call to get preferences etc. This adds logic at client like joining them together something that developers dont like.

Also we need to add multiple pricebooks for each product. Current proposed solution demanded by team was to require network for this operation and get products with price of the pricebook.

As the ideal solution would be to ask for what is needed everytime this isnt real solution as it would degrade performance and would make offline usage impossible.
So I believe that each client probably should just store at a simple local database the data and resync based on some versioning?Products/catalogs change about 1 time per month.

Best Answer

Implement something inspired from etags.

  1. Store the version# of the data on local db.
  2. Make a rest request to check for the version stored on local db vs version on server.
  3. If different, fetch the newer data and store it in db.
Related Topic