How To Disable AFNetworking Cache
Cacheing is handled application-wide by NSURLCache
. If you don't set a shared cache, requests are not cached. Even with a shared NSURLCache
, the default implementation on iOS does not support disk cacheing anyway.
That said, unless you have a very particular reason to write your own cacheing system, I would strongly recommend against it. NSURLCache
is good enough for 99.9% of applications: it handles cache directives from incoming responses and uses them appropriately with new requests, and does so automatically in a way that is unlikely to be a performance bottleneck in your application. As someone who has wasted untold hours making one myself (and later throwing it away since it was completely unnecessary), I'd say that there are much better places to focus your development attention.
AFNetworking disable caching
Cache behavior can be set on NSMutableURLRequest
objects, with setCachePolicy:
. Otherwise, the built-in shared NSURLCache
will respect the caching behavior defined by the server (which I would recommend tuning and taking advantage of, rather than outright disregarding).
AFNetworking - do not cache response
Make long story short, just define your AFNetworking manager:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager.requestSerializer setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
Enjoy!
Unwanted caching a GET request with AFNetworking
If you find out nothing to solve your problem then you can add current time at the end of the url. It happened to me as well and I just added something extra to my url so that it's always a new request.
long currentTime = (long)CFAbsoluteTimeGetCurrent();
NSString *urlString = [NSString stringWithFormat:@"%@%@?%ld",
BASE_URL,
PROFILE_URL,
currentTime];
This is just a workaround. Hope this helps
Related Topics
Sharing an Image Between Two Viewcontrollers During a Transition Animation
Download and Cache Images in Uitableviewcell
Swiftui Generic Pull to Refresh View
What Impact Does Simulated Metrics Have
Swift Force-Unwrapping Exception Not Propagated
How to Disable the Back Navigation Menu in iOS 14+
Uitextfield in Uialertcontroller (Border, Backgroundcolor)
Swift: Retrieving Text from a Uitextfield in a Custom Uitableviewcell and Putting It in an Array
Dismissing Both Uinavigation Views and Modal Views at Once Programmatically
Undefined Symbols for Architecture I386: "_Objc_Class_$_Zipexception", Referenced From: Error
Button Action in Mkannotation View Not Working
Xcode UI Testing Error Keyboard
Tableview Cell How Do We Resize Cell in Swift Along with Image and Label
How to Express Strings in Swift Using Unicode Hexadecimal Values (Utf-16)
Create PDF with Multiple Pages