Clear ID cache when (re-)connecting.

Fixes #5108