From 154bdd5d0ddf1536a30e525920f02d6649cc4f83 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 21 Jun 2013 19:30:41 -0700 Subject: [PATCH] cache item-preview-species on items#show items#show has been very slow recently, and I think it's because there's a lot of querying to be done. Another option would have been to attempt to short-circuit Item#supported_species if not body specific, but that would still leave us with 1s load times for body specific items, which is not satisfactory. The short-circuiting might still be worth doing, but probably not now. I'm also not sure that this is actually the core performance problem, but we'll see. It definitely helped on the dev server: items#show took about 200ms on item pages where everything but species images were cached, then took about 30ms on subsequent loads. Looking like a good candidate. --- app/views/items/show.html.haml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index 51610a89..c0c053fd 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -78,7 +78,13 @@ :class => 'button' #item-preview - #item-preview-species= standard_species_images_for(@item) + #item-preview-species + -# Does this cache ever need to be swept? I don't think so. These days we + -# can identify body-specific items instantly, and, if it's instead + -# particular to a single species, we definitely know that the first time + -# we render. + - localized_cache "items/#{@item.id} item_preview_species" do + = standard_species_images_for(@item) #item-preview-error #item-preview-swf= t '.preview.requirements_not_met'