1
votes

I followed this tutorial on how to compress assets in Heroku.

http://www.cheynewallace.com/serving-compressed-assets-with-heroku-rack-zippy/

Here is my Application.rb file

require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require(*Rails.groups)

module Blog
  class Application < Rails::Application

    config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
    config.exceptions_app = self.routes

    config.cache_store = :memory_store
    Rails.application.config.middleware.swap(ActionDispatch::Static, 
    Rack::Zippy::AssetServer, Rails.public_path)

  end
end

My Gem File

gem 'yui-compressor', '~> 0.12.0'
gem 'rack-zippy'

I ran heroku run rake middleware and got eh following output

use Rack::Sendfile
use Rack::Zippy:AssetServer

Now when I go to Developer Tools and the Network Tab, I see that the size is nearly identical to the content for every asset. Which means the assets were not compressed.

The only similar question I could find was this one

rack-zippy and option -d in production env doesn't serve static assets

And the answer didn't work.

Should I use another Compressor, because it looks like Rack Zippy does not work.

1

1 Answers

2
votes

I had a similar problem. Things started to work when I set config.assets.compile to false on config/environments/production.rb.

In addition is necessary pre-compile the assets before deploy.