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

查看:31
本文介绍了用于在 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/示例代码/URLCache/index.html

说明

URLCache 是一个示例 iPhone 应用程序,它演示了如何从网络下载资源,将其存储在应用程序的数据目录中,以及使用资源的本地副本.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:

  • 网络资源的本地副本应在一段时间(例如,一天)内保持有效,在此期间不会重新检查网络.

  • 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 标头的 Last-Modified 日期来确定 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天全站免登陆