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 86
86:         def cache_page(content, path)
87:           return unless perform_caching
88: 
89:           benchmark "Cached page: #{page_cache_file(path)}" do
90:             FileUtils.makedirs(File.dirname(page_cache_path(path)))
91:             File.open(page_cache_path(path), "wb+") { |f| f.write(content) }
92:           end
93:         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 97
 97:         def caches_page(*actions)
 98:           return unless perform_caching
 99:           actions.each do |action|
100:             class_eval "after_filter { |c| c.cache_page if c.action_name == '#{action}' }"
101:           end
102:         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 76
76:         def expire_page(path)
77:           return unless perform_caching
78: 
79:           benchmark "Expired page: #{page_cache_file(path)}" do
80:             File.delete(page_cache_path(path)) if File.exists?(page_cache_path(path))
81:           end
82:         end

[Validate]