You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rack Middleware Should Only be Used in Development, because it doesn't do much of anything in any environment except development.
Note that the real check for whether the Rack middleware is needed should actually be !Rails.configuration.cache_classes rather than Rails.env.development?. But I'm going to continue using "development" as shorthand....
In development, we want to recompile these files (or at least check them for recompilation) because they could need to be recompiled. But in test/production, the application's stylesheet files don't change. Neither do their dependencies, sub-dependencies, etc. In test/production, if the stylesheet files changed, it's because a new version of the application was deployed and so some of the code was most likely changed as well - in which case the application as a whole will be restarted anyway and the check for recompilation will be done in an initializer. And if the stylesheets' dependencies and sub-dependencies changed, it's because we re-ran bundle install with a newly-deployed version of the application.
Indeed, as Aaron Patterson pointed out, having that one extra middleware can subtly impact performance, especially on performance-critical requests. The reason is that the majority of each request will be spent in a situation where there is an extra frame on the stack, subtly impacting the GC. Obviously the effect is more pronounced if there are twice as many frames on the stack vs. if there is simply one more frame on the stack. But nevertheless test/production don't need the Rack middleware, and could see a subtle performance boost without it.
The text was updated successfully, but these errors were encountered:
I agree in principle, but in practice this is tricky. Currently, Sass will always re-compile if necessary on the first request, even in production. We can't make any changes that would break anyone who's relying on that behavior.
Since Sass is integrated directly into Rails 3.1, I think fixing this isn't worth the effort, so I'm closing it.
Rack Middleware Should Only be Used in Development, because it doesn't do much of anything in any environment except development.
Note that the real check for whether the Rack middleware is needed should actually be
!Rails.configuration.cache_classes
rather thanRails.env.development?
. But I'm going to continue using "development" as shorthand....In development, we want to recompile these files (or at least check them for recompilation) because they could need to be recompiled. But in test/production, the application's stylesheet files don't change. Neither do their dependencies, sub-dependencies, etc. In test/production, if the stylesheet files changed, it's because a new version of the application was deployed and so some of the code was most likely changed as well - in which case the application as a whole will be restarted anyway and the check for recompilation will be done in an initializer. And if the stylesheets' dependencies and sub-dependencies changed, it's because we re-ran bundle install with a newly-deployed version of the application.
Indeed, as Aaron Patterson pointed out, having that one extra middleware can subtly impact performance, especially on performance-critical requests. The reason is that the majority of each request will be spent in a situation where there is an extra frame on the stack, subtly impacting the GC. Obviously the effect is more pronounced if there are twice as many frames on the stack vs. if there is simply one more frame on the stack. But nevertheless test/production don't need the Rack middleware, and could see a subtle performance boost without it.
The text was updated successfully, but these errors were encountered: