What is the equivalent of ~/.cache on macOS?
-
19-04-2021 - |
题
I'm writing a tool that needs to cache files that are supposed to be hidden from the uninformed user and persist across reboots. On Linux, I am putting these files in ~/.cache
. What's the equivalent of that on the mac?
Can I just use ~/.cache
? I also read about ~/Library/Application Support
and ~/Library/Cache
, but I'm finding a lot of contradictory information.
解决方案
The right place to store such files is "Library/Caches" (either in ~ or in the app sandbox, depending on whether or not your app is sandboxed).
Apple documents this fact here:
Especially take note of this quote:
Use this directory to write any app-specific support files that your app can re-create easily. Your app is generally responsible for managing the contents of this directory and for adding and deleting files as needed.