Make cache file names deterministic

Implementing #488, this makes cache file names deterministic.