AFNetwork缓存

AFNetworking uses NSURLConnection which uses NSURLCache shared cache. AFNetworking absolutely transparent in cache regard and doesn't do anything specific. My requests are https and were caching just fine.

Cache-Control response directives allow an origin server to override the default cacheability of a response: private Indicates that all or part of the response message is intended for a single user and MUST NOT be cached by a shared cache. This allows an origin server to state that the specified parts of the response are intended for only one user and are not a valid response for requests by other users. A private (non-shared) cache MAY cache the response. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1

If acceptable try to change policy to public . Log headers on response from the app and look at your cache.db and see if in fact something is caching there.

Try to configure shared cache - something along the lines of

int cacheSizeMemory = 1*1024*1024; // 4MB
int cacheSizeDisk = 100*1024*1024; // 100MB
[[NSURLCache sharedURLCache] setMemoryCapacity:cacheSizeMemory];
[[NSURLCache sharedURLCache] setDiskCapacity:cacheSizeDisk];

Another good read about this here http://petersteinberger.com/blog/2012/nsurlcache-uses-a-disk-cache-as-of-ios5/

你可能感兴趣的:(ios,cache,AFNetwork)