Loading performance between a UIWebView and Safari is considerably different, any pointers?
I have a UIWebView in an iPhone application I am building. It's job is to load up a URL. The code I use is:
NSURL *url = [NSURL URLWithString:providedURL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
This is in viewDidLoad.
I开发者_StackOverflow中文版 have noticed that it takes around 18 seconds for the page to load in my app....but when using Safari it takes 5-8 seconds. Has anyone run into this issue before? Does it have anything to do with how I'm forming my request?
It is likely because Safari has cached the resources of the site already. A basic UIWebView does not do any caching by itself. You'll have to implement that yourself. See a question about that here:
How to cache content in UIWebView for faster loading later on?
精彩评论