在 MAC 上搭建了一个,每打开一个页面差不多得 2 秒钟,都花费再 erb 模板渲染上了,production 环境应该也改善不了多少吧,erb 模板没法缓存。
下面是打开首页时 console 的信息:
Started GET "/" for ::1 at 2015-04-03 21:59:17 +0800 Processing by Spree::HomeController#index as HTML Spree::Preference Load (0.1ms) SELECT "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = ? LIMIT 1 [["key", "spree/frontend_configuration/locale"]] Spree::User Load (0.1ms) SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = ? ORDER BY "spree_users"."id" ASC LIMIT 1 [["id", 1]] Spree::Store Load (0.1ms) SELECT "spree_stores".* FROM "spree_stores" WHERE (url like '%localhost%') ORDER BY "spree_stores"."id" ASC LIMIT 1 Spree::Store Load (0.1ms) SELECT "spree_stores".* FROM "spree_stores" WHERE "spree_stores"."default" = 't' ORDER BY "spree_stores"."id" ASC LIMIT 1 Spree::Order Load (0.0ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = ? AND "spree_orders"."guest_token" = ? AND "spree_orders"."store_id" = ? AND "spree_orders"."user_id" = ? LIMIT 1 [["currency", "USD"], ["guest_token", "Kw4AVot88W6Elx_pi9Tpkw"], ["store_id", 1], ["user_id", 1]] Spree::Order Load (0.1ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = ? AND "spree_orders"."completed_at" IS NULL ORDER BY created_at DESC LIMIT 1 [["user_id", 1]] Spree::Taxonomy Load (0.1ms) SELECT "spree_taxonomies".* FROM "spree_taxonomies" ORDER BY spree_taxonomies.position, spree_taxonomies.created_at Spree::Taxon Load (0.2ms) SELECT "spree_taxons".* FROM "spree_taxons" WHERE "spree_taxons"."parent_id" IS NULL AND "spree_taxons"."taxonomy_id" IN (1, 2) Spree::Taxon Load (0.2ms) SELECT "spree_taxons".* FROM "spree_taxons" WHERE "spree_taxons"."parent_id" IN (1, 2) ORDER BY "lft" Rendered /Users/tini8/.rvm/gems/ruby-2.2.1@rails420/gems/spree_frontend-3.0.0/app/views/spree/shared/_taxonomies.html.erb (13.9ms) (0.3ms) SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM "spree_products" INNER JOIN "spree_variants" ON "spree_variants"."product_id" = "spree_products"."id" AND "spree_variants"."is_master" = 't' AND "spree_variants"."deleted_at" IS NULL INNER JOIN "spree_prices" ON "spree_prices"."variant_id" = "spree_variants"."id" AND "spree_prices"."deleted_at" IS NULL WHERE "spree_products"."deleted_at" IS NULL AND ("spree_products".deleted_at IS NULL or "spree_products".deleted_at >= '2015-04-03 13:59:17.648583') AND ("spree_products".available_on <= '2015-04-03 13:59:17.649115') AND (spree_prices.amount IS NOT NULL) AND "spree_prices"."currency" = 'USD' LIMIT 12 OFFSET 0) subquery_for_count (0.2ms) SELECT MAX("spree_products"."updated_at") FROM "spree_products" INNER JOIN "spree_variants" ON "spree_variants"."product_id" = "spree_products"."id" AND "spree_variants"."is_master" = 't' AND "spree_variants"."deleted_at" IS NULL INNER JOIN "spree_prices" ON "spree_prices"."variant_id" = "spree_variants"."id" AND "spree_prices"."deleted_at" IS NULL WHERE "spree_products"."deleted_at" IS NULL AND ("spree_products".deleted_at IS NULL or "spree_products".deleted_at >= '2015-04-03 13:59:17.648583') AND ("spree_products".available_on <= '2015-04-03 13:59:17.649115') AND (spree_prices.amount IS NOT NULL) AND "spree_prices"."currency" = 'USD' LIMIT 12 OFFSET 0 (0.3ms) SELECT COUNT() FROM "spree_products" INNER JOIN "spree_variants" ON "spree_variants"."product_id" = "spree_products"."id" AND "spree_variants"."is_master" = 't' AND "spree_variants"."deleted_at" IS NULL INNER JOIN "spree_prices" ON "spree_prices"."variant_id" = "spree_variants"."id" AND "spree_prices"."deleted_at" IS NULL WHERE "spree_products"."deleted_at" IS NULL AND ("spree_products".deleted_at IS NULL or "spree_products".deleted_at >= '2015-04-03 13:59:17.648583') AND ("spree_products".available_on <= '2015-04-03 13:59:17.649115') AND (spree_prices.amount IS NOT NULL) AND "spree_prices"."currency" = 'USD' CACHE (0.0ms) SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM "spree_products" INNER JOIN "spree_variants" ON "spree_variants"."product_id" = "spree_products"."id" AND "spree_variants"."is_master" = 't' AND "spree_variants"."deleted_at" IS NULL INNER JOIN "spree_prices" ON "spree_prices"."variant_id" = "spree_variants"."id" AND "spree_prices"."deleted_at" IS NULL WHERE "spree_products"."deleted_at" IS NULL AND ("spree_products".deleted_at IS NULL or "spree_products".deleted_at >= '2015-04-03 13:59:17.648583') AND ("spree_products".available_on <= '2015-04-03 13:59:17.649115') AND (spree_prices.amount IS NOT NULL) AND "spree_prices"."currency" = 'USD' LIMIT 12 OFFSET 0) subquery_for_count CACHE (0.0ms) SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM "spree_products" INNER JOIN "spree_variants" ON "spree_variants"."product_id" = "spree_products"."id" AND "spree_variants"."is_master" = 't' AND "spree_variants"."deleted_at" IS NULL INNER JOIN "spree_prices" ON "spree_prices"."variant_id" = "spree_variants"."id" AND "spree_prices"."deleted_at" IS NULL WHERE "spree_products"."deleted_at" IS NULL AND ("spree_products".deleted_at IS NULL or "spree_products".deleted_at >= '2015-04-03 13:59:17.648583') AND ("spree_products".available_on <= '2015-04-03 13:59:17.649115') AND (spree_prices.amount IS NOT NULL) AND "spree_prices"."currency" = 'USD' LIMIT 12 OFFSET 0) subquery_for_count Spree::Product Load (0.3ms) SELECT "spree_products". FROM "spree_products" INNER JOIN "spree_variants" ON "spree_variants"."product_id" = "spree_products"."id" AND "spree_variants"."is_master" = 't' AND "spree_variants"."deleted_at" IS NULL INNER JOIN "spree_prices" ON "spree_prices"."variant_id" = "spree_variants"."id" AND "spree_prices"."deleted_at" IS NULL WHERE "spree_products"."deleted_at" IS NULL AND ("spree_products".deleted_at IS NULL or "spree_products".deleted_at >= '2015-04-03 13:59:17.648583') AND ("spree_products".available_on <= '2015-04-03 13:59:17.649115') AND (spree_prices.amount IS NOT NULL) AND "spree_prices"."currency" = 'USD' LIMIT 12 OFFSET 0 Spree::Variant Load (0.2ms) SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."deleted_at" IS NULL AND "spree_variants"."is_master" = 't' AND "spree_variants"."product_id" IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) Spree::Price Load (0.2ms) SELECT "spree_prices".* FROM "spree_prices" WHERE "spree_prices"."deleted_at" IS NULL AND "spree_prices"."variant_id" IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) Spree::Image Load (0.3ms) SELECT "spree_assets".* FROM "spree_assets" WHERE "spree_assets"."type" IN ('Spree::Image') AND "spree_assets"."viewable_type" = 'Spree::Variant' AND "spree_assets"."viewable_id" IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) ORDER BY "spree_assets"."position" ASC Rendered /Users/tini8/.rvm/gems/ruby-2.2.1@rails420/gems/spree_frontend-3.0.0/app/views/spree/shared/_products.html.erb (447.9ms) Rendered /Users/tini8/.rvm/gems/ruby-2.2.1@rails420/gems/spree_frontend-3.0.0/app/views/spree/home/index.html.erb within spree/layouts/spree_application (622.9ms) Rendered /Users/tini8/.rvm/gems/ruby-2.2.1@rails420/gems/spree_frontend-3.0.0/app/views/spree/shared/_head.html.erb (189.1ms) Spree::Tracker Load (0.2ms) SELECT "spree_trackers".* FROM "spree_trackers" WHERE "spree_trackers"."active" = 't' ORDER BY "spree_trackers"."id" ASC LIMIT 1 Rendered /Users/tini8/.rvm/gems/ruby-2.2.1@rails420/gems/spree_frontend-3.0.0/app/views/spree/shared/_google_analytics.js.erb (1.1ms) Deface: 1 overrides found for 'spree/shared/_nav_bar' Deface: 'auth_shared_login_bar' matched 1 times with 'li#search-bar' Deface: [ERROR] The original source for 'auth_shared_login_bar' has changed, this override should be reviewed to ensure it's still valid. (0.2ms) SELECT MAX("spree_taxons"."updated_at") FROM "spree_taxons" WHERE "spree_taxons"."parent_id" IS NULL Spree::Taxon Load (0.1ms) SELECT "spree_taxons".* FROM "spree_taxons" WHERE "spree_taxons"."parent_id" IS NULL ORDER BY "spree_taxons"."lft" Rendered /Users/tini8/.rvm/gems/ruby-2.2.1@rails420/gems/spree_frontend-3.0.0/app/views/spree/shared/_search.html.erb (4.5ms) Rendered /Users/tini8/.rvm/gems/ruby-2.2.1@rails420/gems/spree_frontend-3.0.0/app/views/spree/shared/_nav_bar.html.erb (91.6ms) Rendered /Users/tini8/.rvm/gems/ruby-2.2.1@rails420/gems/spree_frontend-3.0.0/app/views/spree/shared/_main_nav_bar.html.erb (2.8ms) Rendered /Users/tini8/.rvm/gems/ruby-2.2.1@rails420/gems/spree_frontend-3.0.0/app/views/spree/shared/_header.html.erb (292.5ms) Rendered /Users/tini8/.rvm/gems/ruby-2.2.1@rails420/gems/spree_frontend-3.0.0/app/views/spree/shared/_sidebar.html.erb (0.2ms) Completed 200 OK in 1593ms (Views: 1582.2ms | ActiveRecord: 3.4ms)