Is there a standard way to service pre-processed gzip assets in Rails 3.2 on Heroku cedars?

I have a Rails 3.2 application that I am deploying on the Kerok Geroku stack. This means that the application itself is responsible for maintaining its static assets. I would like these assets to be gzipped, so I inserted Rack::Deflater into my middleware stack in production.rb :

 middleware.insert_after('Rack::Cache', Rack::Deflater) 

... and curl tells me that it works as advertised.

However, since Heroku is working hard to launch rake assets:precompile , creating a bunch of pre-gzip assets, I would really like to use them (instead of letting Rack::Deflater do all the work again). I saw recipes for serving them with nginx (without using Heroku) and with CDN (I don’t want to use CDN yet), but I did not see anything that could be run separately. I hacked into the middleware rack to do this, but I was wondering if this is the best way to do this?

+6
source share
1 answer

Since the deflater is located after the cache in the rack, the deflator will only need to execute once, and then the compressed assets will be serviced from the cache in the rack (provided that the cache is large enough so that sometimes they do not hit).

However, your middleware looks pretty cool, and you should make it a stone and a blog about it, maybe this will be what people are starting to use :-)

+2
source

Source: https://habr.com/ru/post/911356/


All Articles