Plugins - Addicted To Caching
Add to favoritesBasically, just you add the following to your model:
class Fact < ActiveRecord::Base
acts_as_cache_clearer
end
This adds an after_save and after_destroy that will clear everything in the public directory that is not in the array of protected files and directories.
The list of protected entries that will not be deleted is:
.svn .htaccess 404.html 500.html dispatch.cgi dispatch.fcgi dispatch.rb favicon.ico images javascripts robots.txt stylesheets system
If you have any other files or folders in the public/ directory that you do not want to be deleted when the cached pages are swept, be sure to add it to the list in sweeper.rb.
About
This may or may not be useful to anyone else, but I'll put it out there anyway. It's handy for brochure type websites that have a few dynamic areas. You can simply page cache the entire site and then add acts_as_cache_clearer to all your models. Then, anytime any of those model's records are saved or destroyed, the entire page cache in the public directory is wiped out.
It's currently being used on each page of http://forum.nd.edu/ with the exception of the home page.
http://addictedtonew.com/archives/177/addicted-to-caching/
http://svn.addictedtonew.com/plugins/addicted_to_caching/
Rails' (MIT)
Model
