I posted a similar question here
Serving Compressed Assets in Heroku with Rack-Zippy
but decided to give up on that service, since I couldn\'t get it to work.
As per the author of Rack::Deflater
it should be placed after ActionDispatch::Static
in a Rails app. The reasoning is that if your app is also serving static assets (like on Heroku, for example), when assets are served from disk they are already compressed. Inserting it before would only end up in Rack::Deflater
attempting to re-compress those assets. Therefore as a performance optimisation:
# application.rb
config.middleware.insert_after ActionDispatch::Static, Rack::Deflater