Fixed in PR #1834.

Note: I also caught and fixed my own bug here: if cachename is supplied, it should not skip caching if there is no cachedir.