I'm in the proces of upgrading an app. Currently 3.1.rc8.
The issue is that, in development, on every request, it seems like every single asset gets run through the rails stack. We're talking, every image, js and css file (And there are a whole lot of them). After the first request, they all return 304s, but it is still SO SLOW.
There is a whole lot of this after every request:
Started GET "/assets/jquery-ui-1.8.16.custom.css?body=1" for 127.0.0.1 at 2011-08-30 15:36:21 -0400
Served asset /jquery-ui-1.8.16.custom.css - 304 Not Modified (0ms)
Started GET "/assets/yui.css?body=1" for 127.0.0.1 at 2011-08-30 15:36:21 -0400
Served asset /yui.css - 304 Not Modified (0ms)
How can I make the assets, in development only, get served up like they used to in 3.0.x?
I am also using these tags to prevent my css/js from being compiled into a single file in dev:
= stylesheet_link_tag 'application', :debug => Rails.env.development?
= javascript_include_tag 'application', :debug => Rails.env.development?
Here's my application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
Bundler.require(:default, :assets, Rails.env)
end
module Fooapp
class Application < Rails::Application
config.encoding = "utf-8"
config.filter_parameters += [:password, :password_confirmation]
config.assets.enabled = true
config.assets.version = '1.0'
end
end
and development.rb:
Fooapp::Application.configure do
config.cache_classes = false
config.whiny_nils = true
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = true
config.active_support.deprecation = :log
config.action_dispatch.best_standards_support = :builtin
config.assets.compress = false
config.assets.debug = true
end
Rails is running all of the to_prepare hooks on every Sprockets asset request - and there's a good number of gems that perform a large amount of work in their hooks. (Rails its self is an indirect offender, too, since it's reloading some of your code on every asset request, too)
Rather than waiting for them to optimize their preload hooks (in general, or just for asset requests), take a look at https://github.com/wavii/rails-dev-tweaks. It disables preload hooks (including code reloading) during asset requests.
It's also configurable for any other request type you want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With