Lai Yu-Hsuan
Lai Yu-Hsuan

Reputation: 28071

Page cache doesn't work in Rails

I have an action which needs to be cached:

caches_page :index

def index
  @boards = Board.all
  @boards.shuffle!

  render :layout => false 
end

Really simple. But the problem is, it's not really be cached. Every time I access /boards, Rails re-renders the action. How can I find what's wrong?

I don't change any config in development.rb.

Upvotes: 1

Views: 268

Answers (1)

cailinanne
cailinanne

Reputation: 8372

Is Rails not writing the cached page? Or not reading the cached page? (To see if it's writing the cached page, look in your public directory.)

You do need to set

config.action_controller.perform_caching = true

in your development.rb file. From your comment about not changing your configs, it sounds like that might be your problem.

Upvotes: 3

Related Questions