Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Application.temporaryCachePath -- when does it get cleared?

Discussion in 'Documentation' started by MechEthan, Jul 26, 2016.

  1. MechEthan

    MechEthan

    Joined:
    Mar 23, 2016
    Posts:
    166
    Request for doc clarification on Application.temporaryCachePath:
    1. Under what circumstances will (or may) files under this path be deleted automatically?
    2. Under what circumstances are files stored here guaranteed to NOT be deleted?
    3. Does this behavior vary significantly between platform targets?
    Current docs:

    Platform specific details provided by a Unity employee:

    Edit:
    In particular, I'm afraid to use this on mobile devices if something as simple as the app losing foreground due to user responding to a push can cause the temporaryCachePath to be cleared out.

    Thank you!
     
    Last edited: Jul 26, 2016
    Sir-Gatlin likes this.
  2. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    160
    I've asked the mobile teams but they haven't got back to me yet. In lieu of an answer from them, I'd say store anything you like there, just don't expect it to be there when you want it again, so just check to make sure it exists and fetch it / create it if it doesn't. That is to say, use the temporary cache as a temporary cache - something to speed up things that it would be nice to speed up, but aren't critical. Sorry I can't be more help!
     
    MechEthan likes this.
  3. brunoleos

    brunoleos

    Joined:
    May 14, 2014
    Posts:
    30
    Is this the place where downloaded AssetBundles are cached, so they can be retrieved without downloading again between runs of the application?
     
  4. SirLaur

    SirLaur

    Joined:
    Jan 24, 2014
    Posts:
    22
    @brunoleos I have the same question as you, did you find any answer ?
     
  5. MechEthan

    MechEthan

    Joined:
    Mar 23, 2016
    Posts:
    166
    I ended up writing my own temporary cache code to store and clean-up things in Application.persistentDataPath. Hate reinventing the wheel, but it's faster than reverse engineering behavior of a black box on multiple platforms.
     
    Alex_May likes this.
  6. dorukeker

    dorukeker

    Joined:
    Dec 6, 2016
    Posts:
    37
    I had the same question and came across the below in a different documentation.

    "You can save required files to the Application.temporaryCachePath folder (stored in Library/Caches which is regularly "cleaned out" by the OS) or the Application.persistentDataPath folder (stored in Documents which is not cleaned out by the OS)."

    Which tells me OS is cleaning it in some interval. I know it is not the full answer to the question. Though better than nothing ;-)
     
    Kurt-Dekker likes this.
  7. better_walk_away

    better_walk_away

    Joined:
    Jul 12, 2016
    Posts:
    157
    Yes, this is the place where the bundle caches are stored by Unity. Addressables stores the caches in there as well. But the bundles are something that we would expect to use quite often in game, I don't know why Unity decides to store these kinds of things in the temporary cache folder.
     
unityunity