iPhone:NSURLRequestCachePolicy设置之间的性能差异 [英] iPhone: Performances Differences Between NSURLRequestCachePolicy Settings

查看:131
本文介绍了iPhone:NSURLRequestCachePolicy设置之间的性能差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 NSURLRequest ,各种各样的真实性能差异是什么 NSURLRequestCachePolicy 设置?我特别感兴趣的是缓存策略对用户对UIWebView页面显示速度的感知的影响。

When using NSURLRequest on the iPhone, what are the real world performance differences between the various NSURLRequestCachePolicy settings? I am specifically interested in the cache policy's effect on the the user's perception of the speed at which UIWebView pages display.

我一直在使用默认的 NSURLRequestCachePolicy 但我认为NSURLRequestReloadRevalidatingCacheData可能对大多数情况来说都是最好的,特别是在去的时候回到上一页。

I have been using the default NSURLRequestCachePolicy but I think that perhaps NSURLRequestReloadRevalidatingCacheData could be best for most cases especially when going back to a previous page.

如果您在现实条件下使用了各种缓存策略,哪种策略在特定情况下被证明是最佳的?什么政策提供了三种不同类型的iPhone连接,Wi-Fi,3G和Edge的最佳整体性能?缓存策略是否会对用户对页面加载速度的感知产生任何重大影响,还是应该在其他地方寻找优化UIWebView的显示时间?

If you've used various cache policies under real-world conditions, which policy proved optimum in a particular circumstance? What policy provides the best overall performance over the three different types of iPhone connections, wi-fi, 3G and Edge? Does the cache policy even have any significant effect on the user's perception of page loading speed or should I be looking elsewhere to optimize UIWebView's display time?

似乎有一种共识,即UIWebView似乎忽略了任何NSURLRequest上的缓存设置。我不完全相信这是最后的答案,但是除非有时间进行一些广泛的测试,否则我无法忍受。因此,我接受评价最高的答案。但是,如果问题对您的项目很重要,我会建议您尽量回答。 - TechZen。

There seems to be a consensus that UIWebView appears to ignore the cache settings on any NSURLRequest given it. I do not have complete confidence that this is the final answer but barring the time to do some extensive testing, I cannot gainsay it. Therefore, I am accepting the highest rated answer. However, I would advise that you take the answers with a grain of salt if the matter is of importance to your project. -- TechZen.

推荐答案

我认为这不会对您的UIWebView加载时间产生任何影响。 UIWebView是在WebKit上构建的,它们内部没有使用 NSURLConnection (它们的级别要低得多,使用 CFNetwork 直接)。

I don't think this will make any difference on your UIWebView loading times. UIWebView is built on WebKit, and they're not using NSURLConnection internally (they are at a much lower level and use CFNetwork directly).

这可能不是你想听到的,但加速UIWebView加载时间的最好方法可能是不使用UIWebView。渲染网页非常耗费CPU。实际上,MobileSafari实际上主要是CPU绑定的,而不是网络绑定的 - 例如,注意在滚动时填充棋盘图案需要多长时间。为了快速,快速地加载内容,最好在Cocoa中创建一个本地接口。

This is probably not what you want to hear, but probably the best way to speed up UIWebView loading time is to not use a UIWebView. Rendering web pages is pretty CPU-intensive. In fact, MobileSafari is actually mostly CPU-bound, not network-bound -- notice how long it takes it to fill in that checkerboard pattern when scrolling, for example. For really fast, quickly loading content, it's best to create a native interface in Cocoa.

这篇关于iPhone:NSURLRequestCachePolicy设置之间的性能差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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