instance method caches_page

Ruby on Rails 3.2.22.5

Since v2.2.3 Last seen in v3.2.22.5

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5

Signature

caches_page(*actions)

Caches the actions using the page-caching approach that’ll store the cache in a path within the page_cache_directory that matches the triggering url.

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

Usage:

# cache the index action
caches_page :index

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

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

Parameters

actions rest
Source
# File actionpack/lib/action_controller/caching/pages.rb, line 106
        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

Defined in actionpack/lib/action_controller/caching/pages.rb line 106 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionController::Caching::Pages::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close