I am trying to create a site in RoR and have enabled caching for some pages and actions. The related DB may not accessible every time and hence using the cache is very much required. Hence I cant wait for someone to actually visit the page, render it and then cache it. Instead I want whatever is cache-able to be cached manually, programatically. Is it actually possible or is it that caching is completely automatic in RoR?
A:
Ref :- Link
class ProductsController < ActionController
caches_page :index
def index
end
end
set perform caching to true in your enviorment config/environments/development.rb
config.action_controller.perform_caching = true
Salil
2010-07-01 07:03:44
-1: see quote from the link you provided: "The first time anyone requests products/index, Rails will generate a file called index.html" but the author doesn't want to wait until someone visits the page, he wants it to be cached in advance.
neutrino
2010-07-01 07:08:33
@neutrino: exactly. But is it possible?
Mahesh M
2010-07-01 07:14:52
A:
The lazy* solution would be to visit the page as part of your deployment process with lynx, or even curl. That would trigger the cache event from the outside, but at a time of your choosing.
(*) lazy in a good way, I hope.
Govan
2010-07-01 07:30:19
page-cache plugin is being used. But it doesnt give the whole control from within application. Rake has to be called by cron. Not exactly what I wanted but may be that is the only way.
Mahesh M
2010-07-01 10:56:41