简体   繁体   中英

How to know If the request came from Cache or not using AFNetworking

This is my first day to me with AFNetworking, I like it :) I've only one question,

I've a request and I cached the response, and set the caching policy, How I could know whether the response data is coming from the cache side or the data is loaded from the originating source ?

I need something like

NSLog(@"Cach Used : %@", [request didUseCachedResponse] ? @"YES" : @"NO");

Thanks for your help :)

There is no way to check in programatically if the response coming from cache or not, if the cache policy is set correctly for hhtp requests, your server response contains a valid Cache-Control header, responses will be automatically cached for subsequent requests. If the response comes from the cache it will be fraction earlier than from the server. Here is the link which can give you further info link and AFNetworking FAQ

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM