Cache fixes

Ensure content is utf8 encoded before trying to cache and throw an exception if the json encoding/decoding fails