Page Cache control in radiant cms

Radiant Caching
Radiant cms is very powerful and customizable cms as of now which has inbuilt support for page caching.
Radiant caching mechanisam is somehow similar to action caching in rails.
In latest radiant version i.e. > 0.8 Responsecache has been replaced with Radiant::Cache.
By default radiant cache gets automatically invalidated after every 5 
minutes and that is configurable.
The interval is easily configurable by adding following lines inside environment

if defined? ResponseCache == ‘constant’    

    ResponseCache.defaults[:expire_time] = 4.hours

else

    SiteController.cache_timeout = 4.hours

end

There are situations where automatic cache inavalidation won’t work
and we need to clear radiant cache on the fly.
There are two ways to do that to invalidate radiant cache immediately.
1. Navigate to the root of your Radiant project and delete the cache directory.

cd /home/deploy/radiant_site/tmp

rm -r cache

2. Clearing the page cache from within your code
    

if defined? ResponseCache == ‘constant’

    ResponseCache.instance.clear

else

    Radiant::Cache.clear

end

While building website using radiant cms, it happens that there are certain pages they are static and not going to change frequently that time configuring cache expiry time to long interval is going to be always beneficial and for pages which conatins dynamic content (displaying logged in user on homepage), we need to disable radiant cache for such pages. this can be done by using page_options extension.
Installation for radiant version  0.7
From your RADIANT_ROOT:

$ script/extension install page_options

Installation for radiant version  0.8 and higher

git clone git://github.com/sandipransing/radiant-page_options-extension.git vendor/extensions/page_options

Restart server
Usage
1. Goto /admin/pages
2. Edit any page
3. Click on more link and edit cache settings.
For more information visit

Advertisements

About sandipransing

Web Developer #ruby #rails #JS
This entry was posted in CMS, Radiant, Ruby on Rails and tagged , . Bookmark the permalink.

One Response to Page Cache control in radiant cms

  1. very interesting, learned a lot!.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s