Ben Hoyt
Ben Hoyt

Reputation: 11044

NSURLConnection on iOS doesn't try to cache objects larger than 50KB

Despite Apple's documentation indicating otherwise, NSURLCache on iOS doesn't do any disk (flash) caching at all. You can subclass NSURLCache to change the behaviour of the fetch and store operations to use the disk (like SDURLCache does), but due to the following severe limitations of how the cache is used and implemented, this doesn't work as well as you'd expect:

Has anyone else noticed these issues? Or is there something I'm missing?

FYI, I'm running iOS 4.3 in the simulator and on an iPad 2.

Upvotes: 9

Views: 3810

Answers (4)

Edwin Vermeer
Edwin Vermeer

Reputation: 13127

I'm not sure how it works for a UIWebvieuw, but when you use a NSURLRequest the maximum size of the file depends on how you initialize the URLCache (initWithMemoryCapacity:(NSUInteger)memoryCapacity ...)

Upvotes: 2

steipete
steipete

Reputation: 7641

Check out my fork of AFNetworking that includes a custom class of NSURLCache that supports disk saving: https://github.com/steipete/AFNetworking/tree/disk-cache

Upvotes: 0

Vibhor Goyal
Vibhor Goyal

Reputation: 2425

I'd suggest using ASIHTTPRequest library instead of NSURLRequest:

http://allseeing-i.com/ASIHTTPRequest/How-to-use

It has a robust caching API:

http://allseeing-i.com/ASIHTTPRequest/How-to-use#using_a_download_cache

Upvotes: 3

Malcolm Box
Malcolm Box

Reputation: 4036

I'd suggest using the three20 library and TTURLRequest. This appears to have good caching for large data sizes, since it's used for Facebook and in particular the pictures.

TTURLRequest is pretty much a drop in replacement for a NSURLRequest, so should be easy to move to, and doesn't have much dependency on the rest of Three20

Upvotes: 1

Related Questions