Can someone explain the cache to me?

Hi all

I have been working with OH2 now for over 2 months and love it so far. I did come across my share of problems though, and while searching for solutions in the forum I sometimes read about people referring to the cache and clearing it. I also noticed that sometimes problems only went away after multiple restarts of OH2 (after having applied some solution) and am wondering if this behavior is related to some kind of caching.

I therefore tried reading up on “the cache”, but did not find much so far which would answer my questions:

  • What exactly is the cache used for?
  • Under what circumstances does it need manual “clearing”? (what is best practice)
  • How does one clear it? If manual delete, what exactly needs to be deleted?

I found this directory in my setup: /var/lib/openhab2/cache, I suppose this is what we are talking about. In another post a user talked about deleting /var/lib/openhab2/tmp as well. But karaf also seems to have some cache, I found this mentioned in one of the posts:

  1. Modify: /usr/share/openhab2/runtime/karaf/etc/system.properties and set: karaf.clean.all = true and/or karaf.clean.cache = true
  2. Shutdown the Karaf console with the option (system:shutdown --clean-all)

How is the karaf cache related to all of this?

If this is a RTFM question and is documented somewhere, please point me to the right place(s), I searched and did not find anything.

Thanks in advance.

I can confirm that the cache being referred to is /var/lib/openhab2/cache.

I don’t know fully what is stored there but do know when a binder is installed stuff goes there because deleting the contents of that folder will cause the add-ons to reinstall.

I’ve no idea what is in tmp but know that deleting the contents of tmp and cache is recommended when seeing certain errors and when upgrading (this is done automatically when doing an apt-get upgrade) which.

You should only need to clear the cache if you are seeing errors in the logs that don’t point to a specific binding.