加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 在机架中插入Rack :: Deflater的位置?

发布时间:2020-12-16 19:48:40 所属栏目:百科 来源:网络整理
导读:我目前有以下几个: use Rack::Rewriteuse Rack::Cache,{:verbose=true,:metastore="memcached://localhost:11211/rack-cache/meta",:entitystore="memcached://localhost:11211/rack-cache/body"}use Rack::Rewriteuse Rack::Lockuse Rack::Deflateruse Act
我目前有以下几个:
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响应.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读