问题
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