module ActionController::Caching::Pages::ClassMethods

def cache_page(content, path, extension = nil, gzip = Zlib::BEST_COMPRESSION)

cache_page "I'm the cached content", "/lists/show"
Manually cache the +content+ in the key determined by +path+. Example:
def cache_page(content, path, extension = nil, gzip = Zlib::BEST_COMPRESSION)
  return unless perform_caching
  path = page_cache_path(path, extension)
  instrument_page_cache :write_page, path do
    FileUtils.makedirs(File.dirname(path))
    File.open(path, "wb+") { |f| f.write(content) }
    if gzip
      Zlib::GzipWriter.open(path + '.gz', gzip) { |f| f.write(content) }
    end
  end
end

def caches_page(*actions)

caches_page :image, :gzip => false
# don't gzip images

caches_page :index, :if => Proc.new { |c| !c.request.format.json? }
# cache the index action except for JSON requests

caches_page :index
# cache the index action

Usage:

You can also pass a :gzip option to override the class configuration one.

matches the triggering url.
the cache in a path within the page_cache_directory that
Caches the +actions+ using the page-caching approach that'll store
def caches_page(*actions)
  return unless perform_caching
  options = actions.extract_options!
  gzip_level = options.fetch(:gzip, page_cache_compression)
  gzip_level = case gzip_level
  when Symbol
    Zlib.const_get(gzip_level.to_s.upcase)
  when Fixnum
    gzip_level
  when false
    nil
  else
    Zlib::BEST_COMPRESSION
  end
  after_filter({:only => actions}.merge(options)) do |c|
    c.cache_page(nil, nil, gzip_level)
  end
end

def expire_page(path)

expire_page "/lists/show"
Expires the page that was cached with the +path+ as a key. Example:
def expire_page(path)
  return unless perform_caching
  path = page_cache_path(path)
  instrument_page_cache :expire_page, path do
    File.delete(path) if File.exist?(path)
    File.delete(path + '.gz') if File.exist?(path + '.gz')
  end
end

def instrument_page_cache(name, path)

def instrument_page_cache(name, path)
  ActiveSupport::Notifications.instrument("#{name}.action_controller", :path => path){ yield }
end

def page_cache_file(path, extension)

def page_cache_file(path, extension)
  name = (path.empty? || path == "/") ? "/index" : URI.parser.unescape(path.chomp('/'))
  unless (name.split('/').last || name).include? '.'
    name << (extension || self.page_cache_extension)
  end
  return name
end

def page_cache_path(path, extension = nil)

def page_cache_path(path, extension = nil)
  page_cache_directory.to_s + page_cache_file(path, extension)
end