24 Aug 2012, 14:57
Img_1101_pragsmall

Ben Scheirman (3 posts)

I just finished the book and overall it was really good. Covers an area that is usually glossed over by other books.

I was concerned, however, after reading the chapter on Performance, specifically caching. In this section, there were some very broad statements made that aren’t entirely accurate.

Such as “You can use page caching as long as you don’t need authentication”. This isn’t true if you have any user specific information on the page, including things like the authenticity token. If you do have this, then there are techniques for pulling those in asynchronously once the cached html page is rendered.

The other part I found to be dangerous advice was the part about action caching. “If you need authentication, then use action caching” - The code example proceeds to cache the action with the current user’s creations.

class CreationsController < ApplicationController
  before_filter :authenticate_user!
  caches_action :index

  def index
    @creations = current_user.creations
  end
end

If this isn’t nested in some sort of route based on the user id, then the result is the current user’s cached creations are served to everyone. Am I wrong in this?

I’d suggest making some tweaks to this section for the next edition, or remove it entirely. It’s the glossing over that other books usually leave to the view that this book is doing to caching.

That said, I’m very happy with my purchase and I will be referring to this book often.

Thanks for writing it!

31 Aug 2012, 15:21
_mg_2366_pragsmall

John M Athayde (39 posts)

Ben - Thanks.

Caching is a complex topic, no doubt, and a lot of things have been changing with regards to newer approaches (Russian Doll caching for example). It’s difficult to do a cursory overview of a complex subject and be accurate in all cases.

If we get to a second edition, we’ll be sure to take a look at rewriting this. In the meantime, I’ll try to write some stuff up for the blog.

Thanks for your purchase and please keep the feedback coming!

  You must be logged in to comment