How to check if new JSON file is available?

寵の児 提交于 2019-12-24 03:39:24

问题


I am building a mobile application that get all the information from a Java backend. The data is available through REST in JSON format. How would you manage to discover on the mobile device if the JSON is new or not? I was thinking of having one really simple JSON format file with only a timestamp that the mobile device checked each time to compare to what already stored...but it doesn't seems to be a good solution, at least I think. So are there other ways to do this? I am developing both the backend Java server application and the mobile device app (iOS).


回答1:


Use HTTP Headers including the HTTP ETag. Here's an example in Java.

If-Modified-Since   
Allows a 304 Not Modified to be returned if content is unchanged    

If-None-Match   
Allows a 304 Not Modified to be returned if content is unchanged


来源:https://stackoverflow.com/questions/8669999/how-to-check-if-new-json-file-is-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!