Any way to serve gzip assets from heroku?

删除回忆录丶 提交于 2019-11-30 11:24:49

问题


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.


回答1:


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




回答2:


There's an easier way using a small gem to do this.

Here's article that explains how: http://www.cheynewallace.com/serving-compressed-assets-with-heroku-rack-zippy/




回答3:


Use this gem github.com/mattolson/heroku_rails_deflate



来源:https://stackoverflow.com/questions/12326191/any-way-to-serve-gzip-assets-from-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!