0

After fetching data from server we can store that in DataBase and use that again and again and refresh data if that modified in server like this diagram:

enter image description here

BUT how to found out about server data need to refresh in app without request again?

note : I found some solution like push model but i think HTTP in rest api can resolve this problem, something like @HEAD or etc.

AAV
  • 798
  • 1
  • 6
  • 23

2 Answers2

1

You have to use Push Technology , in which server side sends info when it has new updated info..

in other words we can say "publish and subscribe" model..

Ravindra Bagale
  • 17,226
  • 9
  • 43
  • 70
  • I found some solution like push model but i think rest api can resolve this problem, something like @HEAD or etc. – AAV Oct 14 '20 at 05:50
  • @Ali Vatanparast yes you can use HEAD.. but you dont want to use request again.. thats why i mentioned about push technology – Ravindra Bagale Oct 14 '20 at 06:29
  • HEAD request do not receive body in response , that is really useful here, we can use head request for check change data and after that use original request , yes? – AAV Oct 14 '20 at 06:33
  • 1
    Yes. HEAD is also request.. only difference is server not need to write response body while taking action on HEAD.. it sends status in header.. if there is any change in data then you can return 200 – Ravindra Bagale Oct 14 '20 at 06:38
1

You have no guarantee that the push will be received

The first solution: you need a hash or timestamp. When there is new data on your server, it will update this hash or timestamp. Then you need to check if this hash or timestamp matches. If not, you need to update the data..

Yeldar Nurpeissov
  • 1,786
  • 14
  • 19