Mobile applications in the processing of network resources, generally do offline cache processing, which is the most typical picture cache, where the popular offline cache framework is sdwebimage. However, offline caching takes up storage space on your phone, so the cache cleanup function is basically a standard feature for information, shopping, and reading apps. The implementation of the offline caching feature introduced today is mainly divided into the cache file size acquisition, delete cache file implementation.
Get the size of the cache file
Because the cache file exists in the sandbox, we can use the Nsfilemanager API to calculate the size of the cache file.
Calculate a single File size
Clean up cache files
Also using the Nsfilemanager API for file operations, the Sdwebimage framework itself implements the cleanup cache operation, which we can call directly.
ios-Cleanup Cache