improved caching

I updated the cache to only swap the existing value out if the function runs successfully. For example, if there's a call to get page content, and the content is missing the old content will stay in the cache.

Take a look if the change makes sense. :)