Serving gzipped assets from Rails application

One good practice for your assets is to gzip them and serve them compressed. To do this in your Rails app, you can make use of the Rack::Deflater middleware. Make sure that you use it in your middleware stack, before the middleware that does the handling of static assets.

For example, if you’re using ActionDispatch::Static , you’d want Rack::Deflater before it. Here’s how you do such a thing:

  •  open your config/environments/production.rb
  •  Add this:

config.middleware.insert_before ActionDispatch::Static, Rack::Deflater

See the magic.You can know it from firebug NET All request.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s