updates cache method to encode the incoming string to hopefully avoid OSErrors around filenames being too long