Cache directory vs. temporary directory

The system temporary directory has long been used as a scratch pad in examples. Over time, security limitations (virus scanners) and performance issues (abrupt clearing of system temporary directory) have lead major programs to use user temporary or cache directories instead of the system temporary directory.

The XDG Base Directory specification is a standard for the user cache directory. For systems not implementing the environment variable “XDG_CACHE_HOME”, typical defaults for user cache directory are:

  • Windows %LOCALAPPDATA%
  • macOS ${HOME}/Library/Caches
  • Linux ${HOME}/.cache