I currently have the following:
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
I may be wrong, but wouldn't it make sense to move Deflater to the top? This way any and all traffic is gzipped.
Thanks for the help.
In response to Maletor, for how to exclude certain files from being gzip'd, see:
http://icelab.com.au/articles/wrapping-rack-middleware-to-exclude-certain-urls-for-rails-streaming-responses/
tried it (in Sinatra) and works great.
The simplest way to insert it is directly in your config.ru:
To confirm it is working start up your app and hit it with curl:
Which should return the headers:
And a beautifully gzipped response.
I had to insert it pretty early (before
ActionDispatch::Static
), like this:You can use
rake middleware
to confirm (although this will look at your development settings)