I have subclassed NSURLCache trying to see how caching works. In my app delegate, have this
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0
diskCapacity:50 * 1024 * 1024
diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
My requests are setup like so
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:someUrl
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:10];
But in my NSURLCache subclass
- (NSCachedURLResponse *)cachedResponseForRequest:(NSURLRequest *)request
never gets called. However
- (void)storeCachedResponse:(NSCachedURLResponse *)cachedResponse
forRequest:(NSURLRequest *)request
Does get called.
The headers for my request responses look like
"Cache-Control" = "private, max-age=86224084";
Connection = "keep-alive";
"Content-Length" = 36178;
"Content-Type" = "image/gif";
Date = "Mon, 27 Jul 2015 12:57:35 GMT";
Server = "Microsoft-IIS/7.5";
"X-AspNet-Version" = "4.0.30319";
"X-Powered-By" = "ASP.NET";
Any idea why "cachedResponseForRequest" is not getting called?
Thanks!