I have an app that uses UIWebView to browse websites, after some time I noticed that the cache size of the device is too huge, with some devices it could reach multiple Gaga Bytes
I found that the following folder AppData/Library/Caches/com.myApp/fsCachedData/
is growing with time
Mainly I think the problem happens when navigating through website that sets cache policy to the requests with very big max-age
for example h&m website has max-age=31536000
for the item images
I am using the default NSURLCache
without any modifications, but when I tried to limit the desk capacity as the mentioned here, it didn't prevent the cache size from expanding over the limit
let URLCache = NSURLCache(memoryCapacity: 4 * 1024 * 1024, diskCapacity: 20 * 1024 * 1024, diskPath: nil)
NSURLCache.setSharedURLCache(URLCache)
Any idea how to solve this problem and enforce the system to purge all old cache files automatically?
Note that I am search for a more optimized solution than clearing all the cache using NSURLCache.sharedURLCache().removeAllCachedResponses()