Story Details

  • The practical (Unix) problems with .cache and its friends

    Posted: 2025-02-05 07:26:51

    The blog post argues against using generic, top-level directories like .cache, .local, and .config for application caching and configuration in Unix-like systems. These directories quickly become cluttered, making it difficult to manage disk space, identify relevant files, and troubleshoot application issues. The author advocates for application developers to use XDG Base Directory Specification compliant paths within $HOME/.cache, $HOME/.local/share, and $HOME/.config, respectively, creating distinct subdirectories for each application. This structured approach improves organization, simplifies cleanup by application or user, and prevents naming conflicts. The lack of enforcement mechanisms for this specification and inconsistent adoption by applications are acknowledged as obstacles.

    Summary of Comments ( 41 )
    https://news.ycombinator.com/item?id=42945109

    HN commenters largely agree that standardized cache directories are a good idea in principle but messy in practice. Several point out inconsistencies in how applications actually use $XDG_CACHE_HOME, leading to wasted space and difficulty managing caches. Some suggest tools like bcache could help, while others advocate for more granular control, like per-application cache directories or explicit opt-in/opt-out mechanisms. The lack of clear guidelines on cache eviction policies and the potential for sensitive data leakage are also highlighted as concerns. A few commenters mention that directories starting with a dot (.) are annoying for interactive shell users.