cache_filter plugin released

Hey

I just imported my cache_filter plugin into it's rubyforge subversion repository so it is officially available for public consumption. The plugin let's you keep multiple action_cached versions of the same action's template and uses a custom around_filter (cache_filter) to let you decide which version to serve to the current request.

The cache_filter uses rails' action_caching underneath, and doesn't interfere with Tom Fakes' action_cache plugin in any way. Since Tom's plugin is a drop-in replacement for normal action_caching, my cache_filter plugin will use that instead if installed (tested briefly and with success, haven't tried x-sendfile though, I'd appreciate any feedback on clashes).

The syntax is as follows:

  class WelcomeController < ApplicationController       cache_filter :index, :faq do | cache |         if cache.session[:member_id]           cache.as :logged_in         else           cache.as :not_logged_in         end       end

      def index       end             def faq         @faqs = Faq.find_for_main_faq       end     end

As you can see, you pass the cache_filter method an array of actions and a block you want assigned to them. The special 'as' method tells rails' action_caching which version of the current action's cache to use. You can have more than two versions of course, but a mostly static page with one or two things that need to change due to a user being logged in or not is an excellent example of where you'd have liked to use plain action_caching, but couldn't.

Please checkout the readme though http://rubyforge.org/viewvc/README?revision=1&root=cache-filter&view=markup

The subversion repository resides at svn://rubyforge.org/var/svn/cache-filter

I only finished coding it this morning, so its still in its infancy. If you've any ideas or comments, feel free to mail them to me directly. I'd also like to mention that I developed the plugin to be compatible with trunk revision 5620, but it should work with more recent revisions, including Rails 1.2.

Cheery-o Gustav Paul gustav@rails.co.za

Be sure to create an entry in Ben's plugin directory at http://agilewebdevelopment.com/plugins so other people can find it easily.

Hey all

I've released the second version of the CacheFilter plugin.

I've made many improvements and fixed at least one serious issue. One big enhancement is the availability of the controller's methods when deciding which cached version to serve the request.

The readme is included below:

CacheFilter