Haravikk
Haravikk

Reputation: 3280

What is the Correct Location for Application/Script Cache Files on Unix and Linux?

I'm working on a script which so far has only needed temporary files which I can quite happily throw into /tmp, however I now have some data I've generated that is very costly and time-consuming, so I'd like to store some of it in a cache file somewhere.

Now, on OS X the best location is somewhere in $HOME/Library/Caches, however I'm not sure where the best location is for common versions of Linux and Unix.

I know of /var/caches, but this seems like it should really be used by system services etc. rather than user-specific programs and services. Are there any more correct locations?

I realise some systems may have different preferred locations, so I'd appreciate a summary of some of the main ones, as well as the most compatible options (I'll have my script run through them and pick the best).

Upvotes: 0

Views: 531

Answers (2)

Read the Filesystem Hierarchy Standard (see here) and Linux Standard Base specifications.

For a user application, I would suggest $HOME/.cache/ which is already used by many other applications (mozilla, xfce, ...)

Also, give some advanced way to configure that (thru configuration files, program arguments, or environment variables) and document it.

See also this question (on askubuntu).

Upvotes: 1

yupeng0921
yupeng0921

Reputation: 904

I think /tmp is fine. Or '~/.directory_of_your_script_name' is also fine.

Upvotes: 0

Related Questions