module ActionController::Caching::Pages
def cache_page(content = nil, options = nil)
If no options are provided, the requested url is used. Example:
Manually cache the +content+ in the key determined by +options+. If no content is provided, the contents of response.body is used
def cache_page(content = nil, options = nil) return unless self.class.perform_caching && caching_allowed path = case options when Hash url_for(options.merge(:only_path => true, :format => params[:format])) when String options else request.path end self.class.cache_page(content || response.body, path) end
def caching_allowed
def caching_allowed request.get? && response.status.to_i == 200 end
def expire_page(options = {})
Expires the page that was cached with the +options+ as a key. Example:
def expire_page(options = {}) return unless self.class.perform_caching if options.is_a?(Hash) if options[:action].is_a?(Array) options[:action].dup.each do |action| self.class.expire_page(url_for(options.merge(:only_path => true, :action => action))) end else self.class.expire_page(url_for(options.merge(:only_path => true))) end else self.class.expire_page(options) end end