我可以强制NSURLConnection从缓存加载吗?

编程入门 行业动态 更新时间:2024-10-14 20:23:51
本文介绍了我可以强制NSURLConnection从缓存加载吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

我必须使用NSURLConnection打电话吗?

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

pastie/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

pastie/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从缓存加载吗?

本文发布于:2023-10-31 13:47:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546267.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   加载   NSURLConnection

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!