在机架中的何处插入Rack :: Deflater? [英] Where to insert Rack::Deflater in the rack?
本文介绍了在机架中的何处插入Rack :: Deflater?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前有以下内容:
use Rack::Rewrite
use Rack::Cache, {:verbose=>true, :metastore=>"memcached://localhost:11211/rack-cache/meta", :entitystore=>"memcached://localhost:11211/rack-cache/body"}
use Rack::Rewrite
use Rack::Lock
use Rack::Deflater
use ActionController::Failsafe
use #<Class:0x007fb34be9ac90>
use ActionController::Session::DalliStore, #<Proc:0x007fb34bea3638@(eval):8 (lambda)>
use Rails::Rack::Metal
use ActionController::ParamsParser
use Rack::MethodOverride
use Rack::Head
use ActionController::StringCoercion
use Sass::Plugin::Rack
use Hassle
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
run ActionController::Dispatcher.new
我可能是错的,但是将Deflater移到顶部是否有意义?这样,所有流量都被压缩了.
I may be wrong, but wouldn't it make sense to move Deflater to the top? This way any and all traffic is gzipped.
感谢您的帮助.
推荐答案
最简单的插入方法是直接在您的config.ru中:
The simplest way to insert it is directly in your config.ru:
require ::File.expand_path('../config/environment', __FILE__)
use Rack::Deflater
run My::Application
要确认它是否正常运行,请启动您的应用并用curl打它:
To confirm it is working start up your app and hit it with curl:
curl -i --head "Accept-Encoding: gzip,deflate" http://localhost:5000
应返回标头:
Vary: Accept-Encoding
Content-Encoding: gzip
还有一个漂亮的压缩响应.
And a beautifully gzipped response.
这篇关于在机架中的何处插入Rack :: Deflater?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文