Don't touch cache entires if we don't need to

Updated version of #131 to use type checking