module RefinerycmsVarnish module PageExtension def self.included(base) base.after_save :purge_page base.after_destroy :purge_page base.class_eval do private def purge_page if ((self.respond_to?(:title_changed?) and self.title_changed?) or self.link_url_changed?) and self.show_in_menu # it seems that attributes possibly relevant to other pages have changed # -> we expire all urls ActionController::Base.purge "/", true elsif self.link_url and self.link_url.starts_with?("/") # by now we assume that no attributes relevant to other pages have # changed -> we expire this page only ActionController::Base.purge self.link_url else # by now we know that there is no link_url -> we expire this page only ActionController::Base.purge "/#{self.slug.name}" end if (path = RefinerySetting.find_or_set(:always_purge_path, '')).size > 0 ActionController::Base.purge path end end end end end end