It seems like sometimes the cache-control: max-age in the response is not read.
Actually, I found maybe an explanation for that in the AFURLCache :
- (void)storeCachedResponse:(NSCachedURLResponse *)cachedResponse forRequest:(NSURLRequest *)request
AFCacheableItem *item = [[AFCacheableItem alloc] initWithURL:oURL lastModified:lastModified expireDate:expireDate contentType:contentTypeHeader];
// MUST BE DONE ??
[[AFCache sharedInstance] importCacheableItem:item withData:cachedResponse.data];
the handleResponse: is not called (I added myself), so all the stuff made on headers is not done, only those passed as parameters.
Is it safe to call handleResponse: here ?
Don't use AFURLCache anymore:
Instead, register AFHTTPURLProtocol for http requests, so they'll be routed through AFCache:
[NSURLProtocol registerClass:[AFHTTPURLProtocol class]];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"]];