Create ramdisk on stratup and move .cache folder on it

I want to speed up my system by moving .cache dir to ramdisk. What I need to add to configuration.nix to do this?

I don’t think this will have the intended effect at all.

  1. After booting, applications will be starting with a cold cache. The cache is there because even disk is faster than a cold cache.
  2. As applications use cached files, the kernel will intelligently cache those files in RAM on its own. It’s called the page cache.
  3. Forcing cache files to be in memory instead of letting the kernel decide with its own page cache just means you could be using memory for cache files that would be better spent elsewhere for better performance.

I run fatrace and see very intensive .cache, .config and .mozilla dirs usage by browsers like chromium and firefox, different sites open in background do this… i think they cache some real time data very intensivly… (for example so I think for me there is no need in such intensive caching, to have this relatime data very “hot” and I want to remove this heavy load from my SSD, maybe I can turn some sync period or disable processing of not active tabs in foreground, then this sites in foreground tabs i don’t want they do so many work with my SSD, that’s why for this case i am think to move this dir to ram, to save my disk. I have some freezes of the system, after I disable all logs it’s going better, now I see this intensive .cache. usage and want to some how remove this type of load from ssd.

Yes, browsers do cache things quite a bit. However, those files are being cached by the page cache, so performance is not being affected. I suppose you’re right that it’s putting additional wear on the SSD, but modern SSDs are pretty resilient to this kind of load precisely because it’s the common use case.