Ashley Staggs Ashley Staggs - 11 months ago 99
iOS Question

How To Disable AFNetworking Cache

Is it possible to disable all the cache features from AFNetworking?

I am building my own custom cache system and don't want this to take up disk space too.


Answer Source

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.