Based on the XDG Base Directory Spacifications, $XDG_STATE_HOME should store history and log of the programs. But it is very common to see UNIX programs storing these kind of stuff at $XDG_CACHE_HOME, that is, $HOME/.cache. Why?
Asked
Active
Viewed 2,007 times
2
Rubem Pacelli
- 215
- 1
- 9
1 Answers
4
XDG_STATE_HOME isn’t used much because it’s a recent addition to the specification. Version 0.7 of the specification doesn’t mention it, it was added in version 0.8, published in May 2021.
In previous versions, XDG_CACHE_HOME was the most appropriate location for logs etc. since they arguably qualify as “non-essential”; but it wasn’t great, since they are not cached data.
You should use $XDG_STATE_HOME to store history and logs, and use $XDG_CACHE_HOME only for cached data.
Stephen Kitt
- 411,918
- 54
- 1,065
- 1,164