Caching: fix and improve error reporting (#547).

Note: the Caching plugin depends on the Time plugin.

See #547.