我可以强制NSURLConnection从缓存加载吗? [英] Can I force NSURLConnection to load from cache?

查看:79
本文介绍了我可以强制NSURLConnection从缓存加载吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾考虑过写一个自定义的url缓存,但似乎NSURLCache应该支持磁盘缓存。我想让我的iphone应用程序使用缓存响应,而不打到服务器,直到资源变得陈旧(由我从服务器发回的标头确定)。



我必须使用NSURLConnection打电话吗?

更新:这是一个指向我的代码的链接



http://pastie.org/808549

解决方案

不幸的是,iPhone不能使用NSURLCache进行磁盘缓存,这使得它不适合我概述的场景。



我正在滚动我自己的课程。


I had considered writing a custom url cache, but it seems that NSURLCache is supposed to support a disk cache. I'd like to have my iphone app use cached responses without hitting the server at all until the resource becomes stale (as determined by the headers I send back from the server).

Do I have to call something fancy with NSURLConnection? How can I get the iphone to use the cached version of the url?

Update: Here is a link to my code

http://pastie.org/808549

解决方案

The answer is, unfortunately, that the iPhone can't do disk caching with NSURLCache, making it inappropriate for the scenario I outlined.

I'm rolling my own class.

这篇关于我可以强制NSURLConnection从缓存加载吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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