用于在iPhone上缓存网页的库? [英] Library for Caching Web Pages on iPhone?

查看:147
本文介绍了用于在iPhone上缓存网页的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可用于在本地缓存网页以便在iPhone上进行离线查看的库或框架?如果没有,这样做的最佳策略是什么?

Is there a library or framework that I can use to cache web pages locally for offline viewing on iPhone? If not, what's the best strategy for doing so?

目前我正在考虑的是下载HTML,收集其URL,缓存这些URL,然后重写HTML指向本地文件。这是最好的方法吗?

Currently what I'm thinking of doing is downloading the HTML, harvesting its URLs, caching those URLs, then rewriting the HTML to point to local files. Is that the best way to do it?

谢谢!

推荐答案

看一下Apple的示例代码。具体来说,一个名为URLCache的程序

Take a look at Apple's sample code. Specifically, a program called URLCache

http://developer.apple.com/iphone/library/samplecode/URLCache/index.html

说明

URLCache是​​一个示例iPhone应用程序,演示如何从Web下载资源,将其存储在应用程序的数据目录中,以及如何使用资源的本地副本。 URLCache还演示了如何实现几个缓存策略:

URLCache is a sample iPhone application that demonstrates how to download a resource off the web, store it in the application's data directory, and use the local copy of the resource. URLCache also demonstrates how to implement a couple of caching policies:


  • Web资源的本地副本应在一段时间内保持有效没有重新检查网页的时间(例如,一天)。

  • The local copy of a web resource should remain valid for a period of time (for example, one day) during which the web is not re-checked.

应使用HTTP标头的最后修改日期来确定上次在重新下载之前更改了Web资源。

The HTTP header's Last-Modified date should be used to determine the last time a web resource changed before re-downloading it.

此示例的受众是使用资源等的iPhone开发人员作为从网络上检索或更新的图像。

The audience for this sample is iPhone developers using resources such as images that are retrieved or updated from the web.

这篇关于用于在iPhone上缓存网页的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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