I'm using a NSURLSession
configured to use the shared NSURLCache
. I'm trying to change the size of the cache when the app goes in and out of background. The idea is to reduce both memory and disk capacity when the app enters background and restore the original capacity when the app enters foreground.
For both memoryCapacity
and diskCapacity
properties of NSURLCache
the doc says :
At the time this call is made, the [in-memory|on-disk] cache will truncate its contents to the size given, if necessary.
However, when I set these properties, the cache size never changes even if I set a value (much) lower than currentMemoryUsage
or currentDiskUsage
. Also I can easily verify that the memory used by the app doesn't change, an the size of the disk cache doesn't change either.
It seems that NSURLCache
only use the values set when it is initialized and doesn't take into account subsequent changes. Calling the getters for memoryCapacity
and diskCapacity
does return my new values though.
Am I missing something or doing something wrong or is this a bug of NSURLCache
?