More work to create cache entries

Change the rewriter so that we can use it in combination with
CacheFile.