Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Application.temporaryCachePath -- when does it get cleared?

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

  1. MechEthan


    Mar 23, 2016
    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:

    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


    Dec 29, 2013
    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


    May 14, 2014
    Is this the place where downloaded AssetBundles are cached, so they can be retrieved without downloading again between runs of the application?
    Menion-Leah likes this.
  4. SirLaur


    Jan 24, 2014
    @brunoleos I have the same question as you, did you find any answer ?
    Menion-Leah likes this.
  5. MechEthan


    Mar 23, 2016
    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.
    cengage-jsal and Alex_May like this.
  6. dorukeker


    Dec 6, 2016
    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


    Jul 12, 2016
    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.
  8. retrobrain_dongyi_cai


    Feb 3, 2021
    If you find this thread because of weird behaviour on Linux, that AssetBundle Cache or Addressable Cache is saved in this temp/tmp folder, then I found a solution:

    You can use Caching class and Cache class to specify cache save location. Just add something like this line:
    Code (CSharp):
    1. Caching.currentCacheForWriting = Caching.AddCache(yourPath);
    And these cache will be saved to your own location. For both AssetBundle and Addressable.
    assertor likes this.