如何检查是否有图像的新版本,下载过吗? [英] How to check if have a new version of the image is available, before download?

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

问题描述

我有一个存储在我的web服务器的一些图像。

I have some images that is stored in my WebServer.

所以,我想这始终是用户打开应用程序或刷新,它检查是否有可用的,如果是图像的新版本,下载呢?

So I want that always that the user opens the app or refresh, it check if have a new version of the image available and if yes, download it?

我曾尝试 https://github.com/Julioacarrettoni/iOS-ImageManager ,但这是行不通的,它使重装认为所有的时间。

I have tried https://github.com/Julioacarrettoni/iOS-ImageManager, but it doesn't work, it keeps reloading the view all the time.

谢谢,

推荐答案

有一个为应用程序知道如果图像已经在服务器上更新几种方式:

There are a couple of ways for the app to know if the image has been updated on the server:


  1. 猜测它可能在一周更换一次,而不是担心重新下载时,它不会改变,当它重新下载之前的延迟时间。

  2. 检查时,它是最后一个服务器上修改,下载时,修改日期比你的数据副本更新。

选项1使用HTTP缓存策略信息。选项​​2使用http最后修改标题信息。这两种方法都依赖于服务器提供的响应适当的标题,所以客户端可以决定是否继续或中止请求。

Option 1 uses the http cache policy information. Options 2 uses the http last modified header information. Both options rely on the server providing the appropriate headers in the response so the client can decide whether to continue or abort the request.

在芒替代差是忽略服务器指定的缓存,只有尝试下载图像,每周一次,时间之间使用图像的本地副本。

The poor mans alternative is to just ignore the server specified cache and only try to download the image once per week, using a local copy of the image in between times.

文件的标题:这里。他们是如何实施取决于服务器的建设。

Docs for the headers: here. How they are implemented depends on the construction of your server.

您可能也想看看 SDWebImage

You might also want to look at SDWebImage

这篇关于如何检查是否有图像的新版本,下载过吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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