Sprockets caching during rails 4 asset generation

We are heavy users, working on a large rails 4 application - building assets with assets:precompile takes 3-6 minutes from scratch. I would like to add caching for the sprockets temporary files, but they don’t exist until I build the assets, and I can’t do that until the database is configured and accessible.

Currently, I can make this work - in order to do so I have to override the ‘database’ step and add ‘rake assets:precompile’ in the middle, so it will run before the caches are persisted, which is unpleasant and hack-ish. Is there a better approach or best practice for this?

It looks like database.post runs before the cache gets saved, which helps some. It still feels awkward to build assets during the database phase though.