Reputation: 162
each time i modified my rails stylesheet, it will load very long in development mode.
this is the log and as you can see, the loading takes 90seconds, an average time for each asset modifications.
please help to advise what are the possible issues.
Started GET "/" for ::1 at 2017-12-27 17:54:35 +0800
Processing by StaticPagesController#home as HTML
[1m[35mCart Load (0.0ms)[0m SELECT "carts".* FROM "carts" WHERE "carts"."id" = ? LIMIT 1 [["id", 110]]
[1m[36mAddnew Load (0.0ms)[0m [1mSELECT "addnews".* FROM "addnews" ORDER BY "addnews"."id" ASC LIMIT 1[0m
[1m[35mProduct Load (0.0ms)[0m SELECT "products".* FROM "products" WHERE "products"."id" = ? LIMIT 1 [["id", 10]]
[1m[36mAddnew Load (0.0ms)[0m [1mSELECT "addnews".* FROM "addnews" ORDER BY "addnews"."id" ASC LIMIT 1 OFFSET 1[0m
[1m[35mCACHE (0.0ms)[0m SELECT "products".* FROM "products" WHERE "products"."id" = ? LIMIT 1 [["id", 10]]
[1m[36mAddnew Load (0.0ms)[0m [1mSELECT "addnews".* FROM "addnews" ORDER BY "addnews"."id" ASC LIMIT 1 OFFSET 2[0m
[1m[35mCACHE (0.0ms)[0m SELECT "products".* FROM "products" WHERE "products"."id" = ? LIMIT 1 [["id", 10]]
Rendered static_pages/home.html.erb within layouts/application (1.0ms)
Rendered layouts/_shim.html.erb (1.0ms)
[1m[36m (0.0ms)[0m [1mSELECT COUNT(*) FROM "line_items" WHERE "line_items"."cart_id" = ?[0m [["cart_id", 110]]
[1m[35mLineItem Exists (0.0ms)[0m SELECT 1 AS one FROM "line_items" WHERE "line_items"."cart_id" = ? LIMIT 1 [["cart_id", 110]]
[1m[36mLineItem Load (0.0ms)[0m [1mSELECT "line_items".* FROM "line_items" WHERE "line_items"."cart_id" = ?[0m [["cart_id", 110]]
Rendered layouts/_header_cart_in_total.html.erb (1.0ms)
Rendered layouts/_header_cart.html.erb (13.0ms)
Rendered layouts/_home_header.html.erb (34.0ms)
Rendered shared/_flash.html.erb (0.0ms)
Rendered layouts/_footer.html.erb (0.0ms)
Completed 200 OK in 90627ms (Views: 90615.0ms | ActiveRecord: 0.0ms)
Started GET "/assets/application-46823b452df5e3c7c6257626147e5cf2aa1e9b157ec4229dc94afc4bcb358ad8.css" for ::1 at 2017-12-27 17:56:06 +0800
development.rb parameters uploaded as per requested. rails version is 4.2.4, ruby version is 2.3.3.
Rails.application.configure do
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = true
config.action_mailer.show_previews = true
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
config.assets.debug = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
host = 'localhost:3000'
config.action_mailer.default_url_options = { host: host }
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:port => '587',
:authentication => :plain,
:user_name => ENV["GMAIL_USERNAME"],
:password => ENV["GMAIL_PASSWORD"],
:domain => 'localhost:3000',
:enable_starttls_auto => true
}
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Enable the asset pipeline
end
Upvotes: 1
Views: 695
Reputation: 1430
You can improve asset speed in development. First of all, make sure that CACHING IS ON.
Open this file config/environments/development.rb
config.action_controller.perform_caching = true
Then restart your server.
Assets may compile slowly, but at least make them compile slowly only once, not every time. To ensure assets are cached, make sure caching is on.
Upvotes: 2