离线缓存之RNCachingURLProtocol解析

主要功能:实现 网页离线加载。基本思想来源于AFCache。作者是Rob Napier(IOSX Programming的作者)。

使用方法:

  1. To build, you will need the Reachability code from Apple (included). That requires that you link with SystemConfiguration.framework.

  2. At some point early in the program (usually application:didFinishLaunchingWithOptions:), call the following:

    [NSURLProtocol registerClass:[RNCachingURLProtocol class]];

更多详情,参考http://robnapier.net/offline-uiwebview-nsurlprotocol/简介:将每次的HTTP请求缓存至disk。提交HTTP请求之前,会检查本地是否有缓存。

不主动清除缓存。不适用有太多HTTP请求的环境。

解析:

其他相关:

Mugunth Kumar写了一个基于REST连接的离线缓存工具MKNetworkKit。

详情见下一篇。

posted @ 2014-05-04 10:53  magicya  阅读(1331)  评论(0编辑  收藏  举报