Saving cache data to disk in a plugin

I would like to know if there is a best practice for where or how plugins should store large cached data. The data will be lists of dicts if that makes a difference. If there is no current best practice, what would you recommend I use for best compatibility, and where should I store it on the file system?

I don’t know of any precedent for this, so the answer is probably no, there’s no existing best practice.

If these are sufficiently large files for users to actually care about disk usage, two options might be:

  • add a configuration option to specify the cache path
  • use a system cache directory, like $XDG_CACHE_HOME on Linux (with the disadvantage of needing to distinguish platforms)

Personally, I’m very much annoyed by applications that place their cache in custom places such that I need to manually exclude them from backups.

1 Like

That sounds reasonable. I kind of did both with my most recent project. I put it in a user directory (cross platform) under my application name by default, but let the user ultimately set the location.

Thanks for the input.