Does MacOS periodically purge older files in /Users/<username>/Library/Caches/...?
In the past, I put temp files in /tmp/ folder, and the OS automatically purges them as time goes by.
I'm now considering using the alternative folder /Users/username/Library/Caches/myFolder/ but before I do, I want to make sure that it won't fill-up the user's disk. Will the OS automatically delete older files in that folder?
Solution 1:
In my mind, Caches should not be cleaned by an OS.
In general, the process that generates the cache is responsible for always working - if the cache is missing it should recreate it, it should run periodically and clean the cache or expire old data. Each cache should exist for specific reasons, triggers and expirations so a routine clean up imposed by any OS uniformly on all caches would be a bad design depiction and constrain the usefulness of caches in general.
In specific don’t see macOS ever cleaning ~/Library or /Library cache folders either. I can’t be sure it’s not cleaning at a time I don’t see or just leaving my stuff there alone. There could be low disk space triggers that do clean there and I just don’t run my machines to trigger that occasional cleanup or emergency cleanup if the OS is about to run out of all space.
There are triggers where the OS will just kill running processes when there is no memory, so only Apple could tell you if they have any circumstances where this would be cleaned.