Any way to serve gzip assets from heroku?

12,520

The answer to your question can be found at https://gist.github.com/2152663.

Share:
12,520

Related videos on Youtube

maletor
Author by

maletor

I like bagels, meditation, and music.

Updated on June 26, 2022

Comments

  • maletor
    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 with serve_static_assets from within the rackup file and not in config.middleware.

    A less optimal solution might be to change the default compression level of Zlib which is what Rack::Deflater references. It should only need to gzip once, then it goes to Rack::Cache, then hopefully a CDN.

    A second less optimal solution might be a Rack::Rewrite.

    • willglynn
      willglynn over 11 years
      Someone made a middleware that appears to do what you want: gist.github.com/2152663
    • Joseph Le Brech
      Joseph Le Brech over 11 years
      the 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
      maletor over 11 years
      Which is why the gist above does exactly what I need.
    • Kevin Walsh
      Kevin Walsh almost 11 years
      Another option for serving gzipped assets using Rack::Rewrite gist.github.com/eliotsykes/6049536
  • anka
    anka about 11 years
    To summarize the answer: Use this gem github.com/mattolson/heroku_rails_deflate