ndbroadbent / turbo-sprockets-rails3

Speeds up your Rails 3 assets:precompile by only recompiling changed files, and only compiling once to generate all assets
MIT License
975 stars 78 forks source link

Remove unneeded assets? #22

Closed aaronjensen closed 11 years ago

aaronjensen commented 11 years ago

Should there be a way to clean assets that are no longer referenced by manifest.yml? I saw the ticket to do this with capistrano, but it seems like ata the very least there should be a native way to "tidy up"

ndbroadbent commented 11 years ago

Hey @aaronjensen, that's a great idea. I'm currently working with Heroku on a way to support asset caching, so this is a problem I'm thinking about at the moment.

I think a good general solution would be to remove all assets that aren't referenced by manifest.yml, and were modified more than 7 days ago. This helps to resolve some of the caching issues, and it's a lot simpler when we don't have to support release rollbacks.

Rails 4 (sprockets-rails) is actually going to change the assets:clean task so that it removes unreferences assets, and adds an assets:clobber task which removes all compiled assets.

I think I'll add this behavior to the gem, and let you know when it's done!

ndbroadbent commented 11 years ago

Hi again, I've just released version 0.2.2 with a task that can clean up expired assets. Please see the 'Removing Expired Assets' section in the README for more details. Thanks!

aaronjensen commented 11 years ago

Awesome, that was quick :)

I wonder if another criteria for not removing could be that it was in the previous manfiest.yml? That way even if there are two weeks in between deploys it still keeps the last ones. So both criteria. You'd have to either have a manifest_previous.yml or somehow remember them, but I think that'd be a pretty good solution that'd just work out of the box.

ndbroadbent commented 11 years ago

Great point! Forgot about that, even though I've already handled it in the capistrano task :P

I've just released 0.2.3 which only expires assets older than the previous manifest file. Please see the README section for more info, and let me know your thoughts: https://github.com/ndbroadbent/turbo-sprockets-rails3#removing-expired-assets

aaronjensen commented 11 years ago

Looks great, I'll try it out, thanks!