Network Disk Caching
Clone this wiki locally
As of 0.9.1 Nimbus will no longer use ASIHTTPRequest for the networkimageview feature. This means that network image views will not automatically cache to disk anymore. It is easy to enable disk caching again by using SDURLCache, an implementation of NSURLCache that provides disk cache support.
To enable network disk caching in your application, add SDURLCache.h and SDURLCache.m to your project and then add the following code to your application delegate:
// Nimbus implements its own in-memory cache for network images. Because of this we don't allocate // any memory for NSURLCache. static const NSUInteger kMemoryCapacity = 0; static const NSUInteger kDiskCapacity = 1024*1024*5; // 5MB disk cache SDURLCache *urlCache = [[[SDURLCache alloc] initWithMemoryCapacity:kMemoryCapacity diskCapacity:kDiskCapacity diskPath:[SDURLCache defaultCachePath]] autorelease]; [NSURLCache setSharedURLCache:urlCache];
And you're done. Network requests will now automatically cache their responses to disk, respecting the cache headers accordingly.