Forum: Radiant CMS Excluding certain pages from Radiant cache

Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2010-10-13 04:17
(Received via mailing list)
All,

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

Thanks,
Wes
09477c358c5897d44121a248326e16d7?d=identicon&s=25 Jim Gay (Guest)
on 2010-10-13 04:46
(Received via mailing list)
On Tue, Oct 12, 2010 at 10:16 PM, Wes Gamble <weyus@att.net> 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
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2010-10-13 19:16
(Received via mailing list)
On 10/12/10 9:45 PM, Jim Gay 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
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2010-10-13 19:19
(Received via mailing list)
On 10/12/10 9:45 PM, Jim Gay wrote:
09477c358c5897d44121a248326e16d7?d=identicon&s=25 Jim Gay (Guest)
on 2010-10-13 23:48
(Received via mailing list)
On Wed, Oct 13, 2010 at 1:15 PM, Wes Gamble <weyus@att.net> 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.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2011-02-18 22:29
Jim Gay wrote in post #949713:
> On Tue, Oct 12, 2010 at 10:16 PM, Wes Gamble <weyus@att.net> 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
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2011-02-19 01:43
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
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2011-02-21 22:16
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
This topic is locked and can not be replied to.