Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is any reason why Rack::Deflater gzip is not enabled by default in Ruby on Rails?

Is any reason why Rack::Deflater gzip is not enabled by default in Ruby on Rails? What are the downsides of gzip for rails, if there is any?

like image 983
Razvan Pavel Avatar asked Dec 28 '16 10:12

Razvan Pavel


1 Answers

I don't know the official reason behind this but most obviously they do not do this because there are better places to do gzip compression of responses. Like a frontend proxy or load balancer or your CDN. For example, I use AWS Elastic Beanstalk for deploying Rails applications and I configure the gzip compression on the Elastic Load Balancer (ELB), not inside the Rails application. You want to alleviate your application from doing compression and let it focus on its core business logic. As compressing HTML, CSS and JS is a trivial task that any proxy can do, you want to put that load off your application onto your load balancer. I don't think anyone let's Rack middleware do the compression in production. May be only for very simple and small applications that run on a single instance without load balancer in front. For bigger and complex applications you want your proxy to handle this "work".

like image 97
ralinc Avatar answered Oct 19 '22 06:10

ralinc