ruby-on-rails – 在机架中插入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移到顶部是不是有意义?这样,任何和所有流量都被gzip压缩.

谢谢您的帮助.

解决方法

最简单的插入方式是直接在你的config.ru中:
require ::File.expand_path('../config/environment',__FILE__)
use Rack::Deflater
run My::Application

确认它正在启动你的应用程序并用curl打它:

curl -i --head "Accept-Encoding: gzip,deflate" http://localhost:5000

哪个应该返回标题

vary: Accept-Encoding
content-encoding: gzip

一个精美的gziped响应.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...