Code Monkey home page Code Monkey logo

Comments (9)

SamSaffron avatar SamSaffron commented on July 4, 2024

In general people would use nginx or apache to take care of this, its a lot more efficient than doing it in rails.

To work around this in a way that is rails 4 friendly I would recommend a manual boot.

Just require: false and then in an initializer order it the way you will. see: https://github.com/discourse/discourse/blob/master/config/initializers/06-mini_profiler.rb for an example

I tried to do this automatically but its impossible, it just does not allow reordering of middleware anymore in rails 4 cause it locks up the order.

from rack-mini-profiler.

jjb avatar jjb commented on July 4, 2024

In general people would use nginx or apache to take care of this, its a lot more efficient than doing it in rails.

true, although on heroku it is required to do everything from the rails app. (although now with phusion passenger supporting heroku, they bundle nginx which does compression and image serving)

i'll do the config as you suggested and then patch the readme, standby

from rack-mini-profiler.

jjb avatar jjb commented on July 4, 2024

the Discourse config file doesn't do any ordering and just invokes the regular initializer, right?

Here's what I came up with for the entirety of my initializer, let me know what you think

require 'rack-mini-profiler'

Rack::MiniProfilerRails.initialize!(Rails.application)
Rails.application.middleware.delete(Rack::MiniProfiler)
Rails.application.middleware.insert(1, Rack::MiniProfiler)

from rack-mini-profiler.

SamSaffron avatar SamSaffron commented on July 4, 2024

that looks like it should work,

have a read through the rails tie,

https://github.com/MiniProfiler/rack-mini-profiler/blob/master/lib/mini_profiler_rails/railtie.rb

perhaps we should just add a param there to tell it to skip configuring
middleware eg:


Rack::MiniProfilerRails.initialize!(Rails.application, :skip_middleware => true)

Rails.application.middleware.insert(1, Rack::MiniProfiler)


That way you would not need to add and remove, open to a PR here.

On Tue, Jan 7, 2014 at 8:46 PM, John Bachir [email protected]:

the Discourse config file doesn't do any ordering and just invokes the
regular initializer, right?

Here's what I came up with for the entirety of my initializer, let me know
what you think

require 'rack-mini-profiler'
Rack::MiniProfilerRails.initialize!(Rails.application)Rails.application.middleware.delete(Rack::MiniProfiler)Rails.application.middleware.insert(1, Rack::MiniProfiler)


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-31724499
.

from rack-mini-profiler.

jjb avatar jjb commented on July 4, 2024

Maybe we put the recipe in a "when using deflater" section in the readme, give it a while and see how folks respond and if they have a better idea? it's such a simple recipe so it's not much weight, and also others with a better solution might come out of the woodwork.

btw here's my final config, 0 didn't work for me because my static asset serving also needs to be before deflater.

require 'rack-mini-profiler'
Rack::MiniProfilerRails.initialize!(Rails.application)
Rails.application.middleware.delete(Rack::MiniProfiler)
Rails.application.middleware.insert_after(Rack::Deflater, Rack::MiniProfiler)

So my middleware stack looks like:

use ActionDispatch::GzStatic
use Rack::Deflater
use Rack::MiniProfiler
use Rack::NoWWW
...

from rack-mini-profiler.

SamSaffron avatar SamSaffron commented on July 4, 2024

This seems simple enough for now, mind sending a PR through to update the
readme?

On Wed, Jan 8, 2014 at 2:56 PM, John Bachir [email protected]:

Maybe we put the recipe in a "when using deflater" section in the readme,
give it a while and see how folks respond and if they have a better idea?
it's such a simple recipe so it's not much weight, and also others with a
better solution might come out of the woodwork.

btw here's my final config, 0 didn't work for me because my static asset
serving also needs to be before deflater.

require 'rack-mini-profiler'Rack::MiniProfilerRails.initialize!(Rails.application)Rails.application.middleware.delete(Rack::MiniProfiler)
Rails.application.middleware.insert_after(Rack::Deflater, Rack::MiniProfiler)

So my middleware stack looks like:

use ActionDispatch::GzStaticuse Rack::Deflateruse Rack::MiniProfileruse Rack::NoWWW...


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-31804031
.

from rack-mini-profiler.

jjb avatar jjb commented on July 4, 2024

@SamSaffron done!

from rack-mini-profiler.

SamSaffron avatar SamSaffron commented on July 4, 2024

thanks heaps, should I close this? I tried taking care of this automatically but there is no way I can change middleware in an after initialize hook (its frozen), so this is pretty much the only way short of a monkey patch from hell to rails.

from rack-mini-profiler.

jjb avatar jjb commented on July 4, 2024

yep, i think this is closable, if down the line someone is researching a different solution they can search and find this discussion

from rack-mini-profiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.