如何检查新的JSON文件是否可用? [英] How to check if new JSON file is available?

查看:245
本文介绍了如何检查新的JSON文件是否可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个从Java后端获取所有信息的移动应用程序。数据可通过REST以JSON格式获得。如果JSON是新的,你将如何设法在移动设备上发现?我想有一个非常简单的JSON格式文件,只有一个时间戳,移动设备每次检查时都会与已存储的内容进行比较......但它似乎不是一个好的解决方案,至少我认为。那么有其他方法可以做到这一点吗?我正在开发后端Java服务器应用程序和移动设备应用程序(iOS)。

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).

推荐答案

使用 HTTP标头,包括 HTTP ETag 。这是 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

这篇关于如何检查新的JSON文件是否可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆