Hi all, I'm currently trying to set up caching on my site and am starting by trying to cache my homepage but am having a few problems as although it seems to be caching (in the log I've got 'Cached page: /main.html (0.00048) '), when I reload, it performs all the queries again and doesn't appear to be retrieving the file from the cache.
Just to give you a bit of background, I have a default route set up which states the following:
map.home '', :controller => 'main', :action => "index"
The index action simply queries the database storing the outputs in a hash which is used within the view. I have the following queries within the controller:
def index @hostels=Hostel.count @cities=City.find(:all, :order => "number_of_hostels DESC", :limit => "75", :include => "country") @max_size=City.maximum('number_of_hostels') @review=Review.find(:first, :order => 'updated_at desc') end
In environments/development.rb I have the following line:
config.action_controller.perform_caching = true
In my controller I have the following lines:
caches_page :index
I've been tearing my hair out over this as I can't see why it wouldn't work - would very much appreciate it if someone can point me in the right direction!
One other thing is that this appears to work if I change caches_page to caches_action... Thanks a lot, Jonathan