Any way to serve gzip assets from heroku?
12,520
The answer to your question can be found at https://gist.github.com/2152663.
Related videos on Youtube
Comments
-
maletor almost 2 years
I'm wondering if there is any way to get the Rails webserver (thin) to serve the *.gz files the asset pipeline creates. As I understand, those have a higher compression level than that of
Rack::Deflater
, which only works withserve_static_assets
from within the rackup file and not inconfig.middleware
.A less optimal solution might be to change the default compression level of
Zlib
which is whatRack::Deflater
references. It should only need to gzip once, then it goes toRack::Cache
, then hopefully a CDN.A second less optimal solution might be a
Rack::Rewrite
.-
willglynn over 11 yearsSomeone made a middleware that appears to do what you want: gist.github.com/2152663
-
Joseph Le Brech over 11 yearsthe asset pipeline compiles .gz files as well as regular files, I think pushing that to heroku should work, rack shouldn't have to deflate anything, just serve a .gz instead of a regular asset.
-
maletor over 11 yearsWhich is why the gist above does exactly what I need.
-
Kevin Walsh almost 11 yearsAnother option for serving gzipped assets using Rack::Rewrite gist.github.com/eliotsykes/6049536
-
-
anka about 11 yearsTo summarize the answer: Use this gem github.com/mattolson/heroku_rails_deflate