Excluding certain pages from Radiant cache


#1

All,

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

Thanks,
Wes


#2

On Tue, Oct 12, 2010 at 10:16 PM, Wes G. 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


#3

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


#4

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
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


#5

On Wed, Oct 13, 2010 at 1:15 PM, Wes G. 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.


#6

Jim G. wrote in post #949713:

On Tue, Oct 12, 2010 at 10:16 PM, Wes G. 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


#7

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


#8

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