Suggested maximum size of NSCachesDirectory on iOS

  • Hi,

      on iOS, is there any documentation on how much space an app should use at
    most when storing things in the location returned by NSFileManagers's
    -URLsForDirectory: with NSCachesDirectory? Are there any hard numbers (like for
    example "never more than 1/20th of the entire disk", or something like that)? I
    couldn't find the slightest hint.

    I have an app that potentially produces a lot of cached data (downloaded from
    the network). Caching is highly beneficial to its performance, so generally the
    bigger the cache the better. Still, filling the device up until it's maxed out
    doesn't seem a good thing to do.

    Also, there's no mention on when cached files will get deleted (in case space
    runs out). The only piece of documentation with respect to deletion I came
    across is that cache files *may* not survive an update of the app. However, the
    system surely will (have to) start deleting files before then if it runs out of
    space, no?

    Does anyone have any insights?

    Thanks!
    Regards
    Markus
    --
    __________________________________________
    Markus Spoettl
  • Hi Markus,

    On Sunday, 9. June 2013 at 23:13, Markus Spoettl wrote:

    > on iOS, is there any documentation on how much space an app should use at
    > most when storing things in the location returned by NSFileManagers's
    > -URLsForDirectory: with NSCachesDirectory? Are there any hard numbers (like for
    > example "never more than 1/20th of the entire disk", or something like that)? I
    > couldn't find the slightest hint.

    I don't think they're such rules. And things like 1/20th of the entire disk doesn't make sense either, because it's different number for 16, 32 or 64 GB device. My rules are - wisely utilize all available resources to make user happy. It's balancing on the edge … If you want to feel safer, raise your internal limits …
    > I have an app that potentially produces a lot of cached data (downloaded from
    > the network). Caching is highly beneficial to its performance, so generally the
    > bigger the cache the better. Still, filling the device up until it's maxed out
    > doesn't seem a good thing to do.

    Depends on app, for how long user have to download these data, … If it's kind of magazine app, you can be nice and ask user if you can delete older issue, because download of the new issue can lower disk free space below some limit you have to choose, etc.
    > Also, there's no mention on when cached files will get deleted (in case space
    > runs out). The only piece of documentation with respect to deletion I came
    > across is that cache files *may* not survive an update of the app. However, the
    > system surely will (have to) start deleting files before then if it runs out of
    > space, no?

    To quote docs:

    Cached data should be stored in the <Application_Home>/Library/Caches directory. Examples of files you should put in the Caches directory include (but are not limited to) database cache files and downloadable content, such as that used by magazine, newspaper, and map apps. Your app should be able to gracefully handle situations where cached data is deleted by the system to free up disk space.

    There's no when, but there's that they're.

    Temporary data should be stored in the <Application_Home>/tmp directory. Temporary data comprises any data that you do not need to persist for an extended period of time. Remember to delete those files when you are done with them so that they do not continue to consume space on the user's device.

    Depends on data, sometimes NSTemporaryDirectory() is better. Data in temporary directory are deleted after 3 days IIRC.

    Regards,
    Robert
  • Hi Robert,

    On 6/10/13 8:51 AM, Robert Vojta wrote:
    > /Cached data should be stored in the <Application_Home>/Library/Caches
    > directory. Examples of files you should put in the Caches directory include (but
    > are not limited to) database cache files and downloadable content, such as that
    > used by magazine, newspaper, and map apps. Your app should be able to gracefully
    > handle situations where cached data is deleted by the system to free up disk space./
    >
    > There's no when, but there's that they're.

    That was I was referring to. The fact that there's no talk about limiting the
    use of the cache directory could be seen (by a lazy person such as myself) as
    "use as much as you want, the system will limit it for you".

    Of course the system would not know which files I would want to have deleted
    first, unless it goes by file date (which would actually be what I want). I
    guess we'll never know.

    > /Temporary data should be stored in the <Application_Home>/tmp directory.
    > Temporary data comprises any data that you do not need to persist for an
    > extended period of time. Remember to delete those files when you are done with
    > them so that they do not continue to consume space on the user's device./
    > /
    > /
    > Depends on data, sometimes NSTemporaryDirectory() is better. Data in temporary
    > directory are deleted after 3 days IIRC.

    Caches is the right one for my use.

    Thanks for your response!

    Regards
    Markus
    --
    __________________________________________
    Markus Spoettl
previous month june 2013 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today