Erik Trautman
Erik Trautman

Reputation: 6029

Force Heroku to Recompile All Assets

I updated two images and now Heroku is serving one correctly but the other is still the old image. The output of the deploy logs show both images being precompiled with new hashes but the hash used to retrieve one of them (from the application.css file) is still the old hash and it's grabbing the old image somehow.

I'd like to force Heroku to recompile every asset and restart the server (essentially a fresh deploy). Currently it seems to "intelligently" only precompile the assets that it judges as being new. I tried doing rake assets:clobber and rake assets:precompile but it changed nothing -- still using the old hash to grab the old image version for one, but successfully getting the other. Any other options to try?

Upvotes: 15

Views: 9876

Answers (4)

Yana Agun Siswanto
Yana Agun Siswanto

Reputation: 2032

You can now recompile assets without commiting anything.

heroku plugins:install heroku-repo

and then

$ heroku repo:reset --app=appname
$ git push heroku

Source: https://stackoverflow.com/a/9736959/3034747

This command used to accomplish the same thing, but it has been removed and no longer works:

$ heroku repo:rebuild -a appname

Upvotes: 8

Steve Ellis
Steve Ellis

Reputation: 494

Gross, but make a small change and redeploy.

You have to actually redeploy because that's when asset compilation happens and your slug is compiled. Just restarting the server with heroku restart, changing config variables, or pretty much anything else won't build a new slug for you.

I just ran into this problem, and this was at least what solved it for me; YMMV.

Upvotes: 0

Richard Peck
Richard Peck

Reputation: 76774

Stuff like that can happen - why don't you try using heroku run rake assets:clean and heroku run rake assets:precompile to get the assets cleaned on the server

Upvotes: -1

Erik Trautman
Erik Trautman

Reputation: 6029

Expiring the assets manually worked -- changed config.assets.version = 1.0 to 1.1 in config/production.rb. Still not sure what happened, though.

Upvotes: 21

Related Questions