How To Clear Image cache or any cache in AFNetworking?

后端 未结 5 1542
半阙折子戏
半阙折子戏 2021-02-06 00:30

Hi All can any one help me out how to clear the cache in AFNetworking.

I used to have old version of AFNetworking and i see that it has been updated, Can any body help m

5条回答
  •  深忆病人
    2021-02-06 00:50

    https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ

    Does AFNetworking have any caching mechanisms built-in?

    AFNetworking takes advantage of the caching functionality already provided by NSURLCache and any of its subclasses.

    We recommend you try out Pete Steinberger's fork of SDURLCache, which provides disk caching, which is not otherwise implemented by NSURLCache on iOS. You may find it useful to set ignoreMemoryOnlyStoragePolicy to YES for the SDURLCache instance, which will ensure that images will be cached to disk more consistently for offline use (which, as reported in the SDURLCache README, iOS 5 supports, but only for http, so it still remains a good option if you want to support iOS 4 or https)

    I would also see this question: How To Disable AFNetworking Cache

    Also this: AFNetworking and caching

    The moment you activate the NSURLCache you can specify it's maximum size. You can also clear the cache by calling the removeAllCachedResponses or removeCachedResponsesForRequest methods.

    Hope it helps.

提交回复
热议问题