- Move large assets like PDFs or audio files to asset storage
- Ignore files which are unnecessary to run the app. For example, unit tests, PSDs, or large design documents.
- When possible, reference a released gem by name in your Gemfile rather than loading it from source using the :git option.
I originally had the following in my Gemfile:
gem 'rails', :git => 'git://github.com/rails/rails.git', :branch => '3-1-stable' gem 'sprockets', :git => 'git://github.com/sstephenson/sprockets.git'
When I changed this to
gem 'rails', '3.1.0.rc4' # :git => 'git://github.com/rails/rails.git' ... gem 'sprockets', '2.0.0.beta.10' # :git => 'git://github.com/sstephenson/sprockets.git'my slug size changed from 63 MB to 61 MB (specifically to 61.6 MB). But as Heroku recommends,
The maximum slug size is 100MB. Most apps should be far below this size. Anything under 10MB is good. If you exceed 40MB, you should think about trying to reduce the size of the slug....so I better keep going.
I moved on to #2. I created a .slugignore file with the following contents:
features test spec
In my case, just ignoring these folders in my app reduced my slug size from 61.6 MB to .... 61.6 MB. Negligible difference, unfortunately. I'm suspicious that adding the .slugignore didn't make a difference because when I set up this same app again at a different URL on heroku, the slug size was only 20.5 MB.
After filing a request to Heroku (https://support.heroku.com/requests/27593), I learned that, as the support staff member said, "There is currently a bug in bundler that is not cleaning old versions or unused gems out properly. We are working on upstreaming a fix for this, so hopefully sometime soon your slug size will lessen automatically with a push."
Guess it's back to waiting then. Nonetheless, I hope you found my little investigation above interesting if not helpful.