Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 723
Erik Trautman Avatar asked Mar 06 '14 08:03

Erik Trautman


People also ask

How do I Precompile assets in Heroku?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

How do you Precompile an asset?

We use rake assets:precompile to precompile our assets before pushing code to production. This command precompiles assets and places them under the public/assets directory in our Rails application.

What does rake assets Clean do?

The clean it removes the old versions of the precompiled assets while leaving the new assets in place. Show activity on this post. rake assets:clean removes compiled assets. It is run by cap deploy:assets:clean to remove compiled assets, generally from a remote server.


2 Answers

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

like image 158
Erik Trautman Avatar answered Oct 05 '22 06:10

Erik Trautman


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
like image 21
Yana Agun Siswanto Avatar answered Oct 05 '22 08:10

Yana Agun Siswanto