Module ActionController::Caching::Pages::ClassMethods
In: vendor/rails/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 vendor/rails/actionpack/lib/action_controller/caching.rb, line 90
90:         def cache_page(content, path)
91:           return unless perform_caching
92: 
93:           benchmark "Cached page: #{page_cache_file(path)}" do
94:             FileUtils.makedirs(File.dirname(page_cache_path(path)))
95:             File.open(page_cache_path(path), "wb+") { |f| f.write(content) }
96:           end
97:         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 vendor/rails/actionpack/lib/action_controller/caching.rb, line 101
101:         def caches_page(*actions)
102:           return unless perform_caching
103:           actions = actions.map(&:to_s)
104:           after_filter { |c| c.cache_page if actions.include?(c.action_name) }
105:         end

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

  expire_page "/lists/show"

[Source]

    # File vendor/rails/actionpack/lib/action_controller/caching.rb, line 80
80:         def expire_page(path)
81:           return unless perform_caching
82: 
83:           benchmark "Expired page: #{page_cache_file(path)}" do
84:             File.delete(page_cache_path(path)) if File.exist?(page_cache_path(path))
85:           end
86:         end

[Validate]