Fixes #5523: Generate cache in a configurable directory