I have a Radiant-based site that I need to run without any caching,
because information about the currently logged in user (or a login
box) is part of the site design.
I thought disabling caching was just a matter of setting:
ResponseCache.defaults[:perform_caching] = false
- in environment.rb or production.rb, but this doesn’t seem to have
any effect - this setting seems to be completely ignored by
ResponseCache?
It is in fact this code in SiteController that determines if a page is
cached:
def show_uncached_page(url)
…
@cache.cache_response(url, response) if request.get? and live?
and @page.cache?
…
end
- which means that the page will have to return false to avoid
caching. Since the default Page class is hardcoded to return true, I
either have to override this setting, or create a new UncachedPage
type which I use for all pages. The first solution is ugly, but
nevertheless the way I ended up doing it, since the second solution is
unfeasible when admins start creating their own pages and so on.
Is there a way to disable caching site-wide I have overlooked, or is
Radiant simply designed this way?
Cheers,
Casper F.
Casper,
Confirm that your individual environment files (config/environment) do
not override the default you have set. You can do this by putting that
setting outside the initializer block, or by changing the value in the
individual environment files.
Sean
Sean,
Thanks for your answer. I already did that. I also looked through the
code of ResponseCache. Where does it use the “perform_caching”
setting, because I for one can’t find it? I’m not pointing any fingers
here, I’m just asking, is anyone actually running Radiant with caching
completely disabled and can confirm that it can be disabled?
Cheers,
Casper
Thanks for your answer. I already did that. I also looked
through the
code of ResponseCache. Where does it use the “perform_caching”
setting, because I for one can’t find it? I’m not pointing
any fingers
here, I’m just asking, is anyone actually running Radiant
with caching
completely disabled and can confirm that it can be disabled?
In ResponseCache, the expire_page, cache_page and update_response
methods use ‘return unless perform_caching’ to no-op if caching is
disabled.
Dan.
Dan, you’re right, and I must have been blind when I wrote my previous
mail. Now that I see that the setting is in fact used by
ResponseCache, it must obviously be a problem with my config-files.
Thanks,
Casper