MKNetworkKit 网上已有不少介绍它的文章了，不过对于它提供的众多特性的实现机制，还是值得研究研究的。其中 Auto caching 是其中之一。
High performance background caching (based on HTTP 1.1 caching specs) built in
MKNetworkKit can automatically cache all your “GET” requests. When you make the same request again, MKNetworkKit calls your completion handler with the cached version of the response (if it’s available) almost immediately. It also makes a call to the remote server again. After the server data is fetched, your completion handler is called again with the new response data. This means, you don’t have to handle caching manually on your side. All you need to do is call one method
[[MKNetworkEngine sharedEngine] useCache];
Optionally, you can override methods in your MKNetworkEngine subclass to customize your cache directory and in-memory cache cost.
- 它是基于 HTTP1.1 协议设计的Cache模式，刚好我们请求的后端服务也是基于这个协议，Cache-Control 用的是 max-age=0, private, must-revalidate , ETag 标记缓存