More work on messages cache

Needed to ensure directory was created if it didn't already exist.