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.
Rack::Deflater
should work if you use insert_before
(instead of "use"), to place it near the top of the middleware stack, prior to any other middleware that might send a response. .use
places it at the bottom of the stack. On my machine the topmost middleware is Rack::Sendfile
. So I would use:
config.middleware.insert_before(Rack::Sendfile, Rack::Deflater)
You can get the list of middleware in order of loading by doing rake middleware
from the command line.
Note: A good link for insert_before vs Use in middleware rack