# Caching

**URL:** <https://www.ruby-forum.com/t/caching/89608>\
**Category:** Radiant CMS\
**Created:** [March 21, 2007, 4:20pm UTC](https://www.ruby-forum.com/t/caching/89608 "2007-03-21T16:20:43Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [March 21, 2007, 4:20pm UTC](https://www.ruby-forum.com/t/caching/89608/1 "2007-03-21T16:20:43Z")

</div>

Hi,

In production mode, Radiant uses page level caching right?

Settings (environment.rb and environments/production.rb) look like page  
level  
caching, but I thought page level caching wrote files to the public/  
directory?  
I’m confused on the pages being cached as .yml in the cache/ directory?

I sincerely apologize if the answers are found someplace obvious. I’ve  
tried  
searching the past mailing lists and site. I’m not sure, but maybe this  
is  
related to:

[http://dev.radiantcms.org/radiant/ticket/474](http://dev.radiantcms.org/radiant/ticket/474)

Todd

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [March 21, 2007, 6:41pm UTC](https://www.ruby-forum.com/t/caching/89608/2 "2007-03-21T18:41:04Z")

</div>

Todd McGrath wrote:

> In production mode, Radiant uses page level caching right?
> 
> Settings (environment.rb and environments/production.rb) look like page level  
> caching, but I thought page level caching wrote files to the public/ directory?  
> I’m confused on the pages being cached as .yml in the cache/ directory?

Radiant uses a custom caching system built on top of the Rails caching  
system (I believe that would be page level caching). Files are cached as  
yaml because the entire response is cached including the headers–not  
just the HTML.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [March 21, 2007, 11:49pm UTC](https://www.ruby-forum.com/t/caching/89608/3 "2007-03-21T23:49:58Z")

</div>

> Rails caching  
> system (I believe that would be page level caching). Files  
> are cached as  
> yaml because the entire response is cached including the headers–not  
> just the HTML.

The caching in radiant is most similar to rails action caching, not page  
caching. The radiant custom cache has caused a few problems  
for people trying to do session-based things with radiant code, but it  
significantly outperforms the rails action cache (or at  
least, it does in the mental branch).

Dan.

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [March 22, 2007, 3:22am UTC](https://www.ruby-forum.com/t/caching/89608/4 "2007-03-22T03:22:13Z")

</div>

> The caching in radiant is most similar to rails action caching, not page  
> caching. The radiant custom cache has caused a few problems  
> for people trying to do session-based things with radiant code, but it  
> significantly outperforms the rails action cache (or at  
> least, it does in the mental branch).

Can I set cache options, expire\_time for instance, outside of editting  
the  
response\_cache.rb file directly?

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [March 22, 2007, 3:59am UTC](https://www.ruby-forum.com/t/caching/89608/5 "2007-03-22T03:59:18Z")

</div>

Todd McGrath wrote:

> > The caching in radiant is most similar to rails action caching, not page  
> > caching. The radiant custom cache has caused a few problems  
> > for people trying to do session-based things with radiant code, but it  
> > significantly outperforms the rails action cache (or at  
> > least, it does in the mental branch).
> 
> Can I set cache options, expire\_time for instance, outside of editting the  
> response\_cache.rb file directly?

You sure can. Take a look at the environment files in  
config/environments/.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [March 22, 2007, 4:41am UTC](https://www.ruby-forum.com/t/caching/89608/6 "2007-03-22T04:41:22Z")

</div>

Todd McGrath wrote:

> > > Can I set cache options, expire\_time for instance, outside of editting the  
> > > response\_cache.rb file directly?  
> > > You sure can. Take a look at the environment files in config/environments/.  
> > > Example to set the timeout from default of 5 to 10 minutes:  
> > > ResponseCache.defaults[:expire\_time] = 600

Or:

ResponseCache.defaults[:expire\_time] = 5.minutes

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [March 22, 2007, 4:04am UTC](https://www.ruby-forum.com/t/caching/89608/7 "2007-03-22T04:04:19Z")

</div>

> > Can I set cache options, expire\_time for instance, outside of editting the  
> > response\_cache.rb file directly?
> 
> You sure can. Take a look at the environment files in config/environments/.

Thanks,

I think I got it? -

Example to set the timeout from default of 5 to 10 minutes:  
ResponseCache.defaults[:expire\_time] = 600

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [March 23, 2007, 4:25pm UTC](https://www.ruby-forum.com/t/caching/89608/8 "2007-03-23T16:25:26Z")

</div>

I’m running Radiant 0.6.0rc2

Is there any way to disable caching of Radiant generated pages AND  
plugin code when running in development mode? Having to clear the page  
cache after every plugin code change is slowing me down.

In order to not cache Radiant pages I had to set the following in  
/config/environments/development.rb  
config.cache\_classes = true  
ResponseCache.defaults[:perform\_caching] = false

Setting the first flag to true seems odd, but I couldn’t turn off  
caching any other way.

My plugin code, which injects some HTML into the page through a radiant  
tag, seems to always be cached nomatter what I set config.cache\_classes  
to.

Any ideas?

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [July 9, 2007, 4:18pm UTC](https://www.ruby-forum.com/t/caching/89608/9 "2007-07-09T16:18:00Z")

</div>

> Any ideas?

I have tried to track this bug with Aptana debugger on Windows.  
I’m using Radiant 0.6.2 (gem) with WEBrick server on my development  
machine.

The problem is: ResponseCache instance is not living during whole server  
lifespan. It is recreated on every page request.

First time, when server is being started, ResponseCache instance is  
created with right default options (:perform\_caching is false as  
specified in development.rb). But then happily dies.

On every consequent page request ResponseCache is created again, but  
with original defaults as specified in  
radiant-0.6.2/app/models/response\_cache.rb.

My solution:  
I ended up, modifing radiant-0.6.2/app/models/response\_cache.rb on my  
development machine and forcing :perform\_caching to be false in  
initialize call.

Caching is disabled as expected, but to see modified content of my  
extension I need hit a browser refresh button two times (maybe it is  
somehow connected to extension caching or rails caching). Anyway, it  
works much better for me now.

That’s my $0.02. I’m a ruby, rails and radiant newbie, I may be totally  
wrong.

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [July 10, 2007, 4:32am UTC](https://www.ruby-forum.com/t/caching/89608/10 "2007-07-10T04:32:23Z")

</div>

> I have tried to track this bug with Aptana debugger on Windows.  
> I’m using Radiant 0.6.2 (gem) with WEBrick server on my development  
> machine.
> 
> The problem is: ResponseCache instance is not living during  
> whole server  
> lifespan. It is recreated on every page request.

Yes, the ResponseCache instance is constantly recreated, but the  
ResponseCache class isn’t being reloaded, and the defaults are  
stored at the class level. (well, the class should not be reloaded, and  
as far as I can tell it isn’t).

Editing the ResponseCache settings should be done like so:

ResponseCache.defaults[:perform\_caching] = false  
ResponseCache.defaults[:expire\_time] = 10.minutes

in the development.rb file.

To test, I added a new tag in standard\_tags.rb:

tag ‘response\_cache\_settings’ do |tag|  
ResponseCache.defaults.inspect  
end

included that tag on my homepage, started up the site and accessed the  
page a few times - it consistently gave back the expected  
values.

Dan.

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [June 1, 2007, 7:24pm UTC](https://www.ruby-forum.com/t/caching/89608/11 "2007-06-01T19:24:23Z")

</div>

David P. wrote:

> I’m running Radiant 0.6.0rc2
> 
> Is there any way to disable caching of Radiant generated pages AND  
> plugin code when running in development mode? Having to clear the page  
> cache after every plugin code change is slowing me down.
> 
> In order to not cache Radiant pages I had to set the following in  
> /config/environments/development.rb  
> config.cache\_classes = true  
> ResponseCache.defaults[:perform\_caching] = false
> 
> Setting the first flag to true seems odd, but I couldn’t turn off  
> caching any other way.
> 
> My plugin code, which injects some HTML into the page through a radiant  
> tag, seems to always be cached nomatter what I set config.cache\_classes  
> to.
> 
> Any ideas?

Now using Radiant 0.6.1 on a new project and I’m still having trouble  
with disabling both class and page caching. Any way I need to  
specifically setup environment/development.rb?

config.cache\_classes = false

# Show full error reports and caching is turned off, but ResponseCache

caching is on  
config.action\_controller.consider\_all\_requests\_local = true  
config.action\_controller.perform\_caching = false  
ResponseCache.defaults[:perform\_caching] = true

# setting expire\_time does not help at all

ResponseCache.defaults[:expire\_time] = 10.seconds

Also, from the commented line above, what is the difference between  
“caching” and “ResponseCache caching”?

Thanks,

- Dave

---

<div class="post-metadata">

**Author:** ![Todd\_McGrath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@Todd\_McGrath](https://www.ruby-forum.com/u/Todd_McGrath)\
**Post date:** [August 9, 2007, 1:41am UTC](https://www.ruby-forum.com/t/caching/89608/12 "2007-08-09T01:41:34Z")

</div>

> On every consequent page request ResponseCache is created again, but  
> with original defaults as specified in  
> radiant-0.6.2/app/models/response\_cache.rb.

I avoided this by adding this line to the “activate” def of a custom  
extension:

ResponseCache.defaults[:perform\_caching] = false
