Comments (9)
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.
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.
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.
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 thinkrequire '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.
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.
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.
@SamSaffron done!
from rack-mini-profiler.
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.
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)
- Clicking "more" in speed badge causes an HTTP request, which doesn't work for HTTPS-only servers
- View previously captured flamegraphs
- Optionally (via config? keyboard shortcut?) show URL or controller action name in the badge itself
- "No snapshots exist" with snapshots enabled
- When `data-vertical-position` is `bottom`, then the popup is not positioned correctly
- always-async-flamegraph mode HOT 1
- Question: Support for tracing forked processes HOT 2
- Display row counts in the UI
- Latest release has an issue ...undefined local variable or method `query_string' HOT 2
- Deprecation warning with Rack >= 3.0.0 - Rack::File is deprecated and will be removed in Rack 3.1
- PRs for dotnet not being handled HOT 1
- "Display name in badge" commit accidentally affects SQL table number alignment
- Compliance with Rack : Spec 3. Lower-case HTTP Headers
- `alias_method': undefined method HOT 8
- MiniProfiler storage failure: can't modify frozen HOT 2
- Badge no longer displays after Turbo Drive page load w/ Turbo 8 (even w/ enable_hotwire_turbo_drive_support = true) HOT 2
- Assets served from Rails deauthorizing client-side profiler
- SQL queries are not profiled for Non-Rails Applications if rails patch is not enabled HOT 1
- Incompabtibility with rack 3/warden/devise HOT 1
- Don't touch HTTP headers where possible HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rack-mini-profiler.