Module ActionController::Caching::Pages::ClassMethods
In: actionpack/lib/action_controller/caching.rb

Methods

Public Instance methods

Manually cache the content in the key determined by path. Example:

  cache_page "I'm the cached content", "/lists/show"

[Source]

# File actionpack/lib/action_controller/caching.rb, line 90
        def cache_page(content, path)
          return unless perform_caching

          benchmark "Cached page: #{page_cache_file(path)}" do
            FileUtils.makedirs(File.dirname(page_cache_path(path)))
            File.open(page_cache_path(path), "wb+") { |f| f.write(content) }
          end
        end

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.

[Source]

# File actionpack/lib/action_controller/caching.rb, line 101
        def caches_page(*actions)
          return unless perform_caching
          actions.each do |action|
            class_eval "after_filter { |c| c.cache_page if c.action_name == '#{action}' }"
          end
        end

Expires the page that was cached with the path as a key. Example:

  expire_page "/lists/show"

[Source]

# File actionpack/lib/action_controller/caching.rb, line 80
        def expire_page(path)
          return unless perform_caching

          benchmark "Expired page: #{page_cache_file(path)}" do
            File.delete(page_cache_path(path)) if File.exists?(page_cache_path(path))
          end
        end

Private Instance methods

[Source]

# File actionpack/lib/action_controller/caching.rb, line 109
          def page_cache_file(path)
            name = ((path.empty? || path == "/") ? "/index" : URI.unescape(path))
            name << page_cache_extension unless (name.split('/').last || name).include? '.'
            return name
          end

[Source]

# File actionpack/lib/action_controller/caching.rb, line 115
          def page_cache_path(path)
            page_cache_directory + page_cache_file(path)
          end

[Validate]