# Excluding certain pages from Radiant cache

**URL:** <https://www.ruby-forum.com/t/excluding-certain-pages-from-radiant-cache/197347>\
**Category:** Radiant CMS\
**Created:** [October 13, 2010, 4:17am UTC](https://www.ruby-forum.com/t/excluding-certain-pages-from-radiant-cache/197347 "2010-10-13T04:17:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [October 13, 2010, 4:17am UTC](https://www.ruby-forum.com/t/excluding-certain-pages-from-radiant-cache/197347/1 "2010-10-13T04:17:24Z")

</div>

All,

Is there a way to keep a specific page from being cached by Radiant?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [October 13, 2010, 4:46am UTC](https://www.ruby-forum.com/t/excluding-certain-pages-from-radiant-cache/197347/2 "2010-10-13T04:46:13Z")

</div>

On Tue, Oct 12, 2010 at 10:16 PM, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> All,
> 
> Is there a way to keep a specific page from being cached by Radiant?
> 
> Thanks,  
> Wes

You could make a custom page class and turn it off.

class NoCachePage \< Page  
def cache  
false  
end  
end

You could also take a look at  
[http://ext.radiantcms.org/extensions/123-page-options](http://ext.radiantcms.org/extensions/123-page-options)

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [October 13, 2010, 7:19pm UTC](https://www.ruby-forum.com/t/excluding-certain-pages-from-radiant-cache/197347/3 "2010-10-13T19:19:14Z")

</div>

On 10/12/10 9:45 PM, Jim G. wrote:

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [October 13, 2010, 7:16pm UTC](https://www.ruby-forum.com/t/excluding-certain-pages-from-radiant-cache/197347/4 "2010-10-13T19:16:07Z")

</div>

On 10/12/10 9:45 PM, Jim G. wrote:

> class NoCachePage\< Page  
> def cache  
> false  
> end  
> end
> 
> You could also take a look at  
> [http://ext.radiantcms.org/extensions/123-page-options](http://ext.radiantcms.org/extensions/123-page-options)  
> The page-options extension appears to no longer be compatible with  
> Radiant (it was written at Radiant 0.7), per:

def cache\_setting  
@page = Page.find(self.id)  
case true  
when @page.cache\_expire\_minutes == 0 && @page.cache\_expire\_time  
== nil: “Default”  
when @page.cache\_expire\_minutes == -1: “No Caching”  
when @page.cache\_expire\_minutes == 1: “1 minute”  
when @page.cache\_expire\_minutes \> 1:  
“#{@page.cache\_expire\_minutes} minutes”  
when @page.cache\_expire\_time != nil &&  
@page.cache\_expire\_time.is\_a?(Time)  
“Daily at  
#{@page.cache\_expire\_time.strftime(”%H")}:#{@page.cache\_expire\_time.strftime(“%M”)}"  
else “Not set”  
end  
end

“cache\_expire\_minutes” and “cache\_expire\_time” are no longer page  
attributes, and as far as I can tell, all of the caching is not being  
managed through HTTP response headers, is that correct?

Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [October 13, 2010, 11:48pm UTC](https://www.ruby-forum.com/t/excluding-certain-pages-from-radiant-cache/197347/5 "2010-10-13T23:48:15Z")

</div>

On Wed, Oct 13, 2010 at 1:15 PM, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > You could make a custom page class and turn it off.  
> > The page-options extension appears to no longer be compatible with Radiant  
> > minutes"  
> > managed through HTTP response headers, is that correct?
> 
> Wes

Caching is handled via HTTP headers and RackCache, but the  
page\_options extension adds fields to each page to control this.  
I’ve not used it, so perhaps others can jump in here.

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 18, 2011, 10:29pm UTC](https://www.ruby-forum.com/t/excluding-certain-pages-from-radiant-cache/197347/6 "2011-02-18T22:29:44Z")

</div>

Jim G. wrote in post #949713:

> On Tue, Oct 12, 2010 at 10:16 PM, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > All,
> > 
> > Is there a way to keep a specific page from being cached by Radiant?
> > 
> > Thanks,  
> > Wes
> 
> You could make a custom page class and turn it off.
> 
> class NoCachePage \< Page  
> def cache  
> false  
> end  
> end

If I made a custom page class to handle this, how would I assign  
particular pages to it?

Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 21, 2011, 10:16pm UTC](https://www.ruby-forum.com/t/excluding-certain-pages-from-radiant-cache/197347/7 "2011-02-21T22:16:31Z")

</div>

I ended up defining a non-cacheable page like so:

class NonCacheablePage \< Page  
def cache?  
false  
end  
end

and it works well.

Many thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [February 19, 2011, 1:43am UTC](https://www.ruby-forum.com/t/excluding-certain-pages-from-radiant-cache/197347/8 "2011-02-19T01:43:27Z")

</div>

Interesting - I tried this:

Page

class Page \< ActiveRecord::Base  
DENY\_CACHING\_PATHS = [’/’]

def cache?  
! DENY\_CACHING\_PATHS.include?(slug)  
end  
end

as an initializer but the expires header for ‘/’ still came out at ~5  
min.

Will need to dig deeper.

W
