Module | ActionController::Caching::Pages::ClassMethods |
In: |
vendor/rails/actionpack/lib/action_controller/caching.rb
|
Manually cache the content in the key determined by path. Example:
cache_page "I'm the cached content", "/lists/show"
# File vendor/rails/actionpack/lib/action_controller/caching.rb, line 85 85: def cache_page(content, path) 86: return unless perform_caching 87: 88: benchmark "Cached page: #{page_cache_file(path)}" do 89: FileUtils.makedirs(File.dirname(page_cache_path(path))) 90: File.open(page_cache_path(path), "wb+") { |f| f.write(content) } 91: end 92: 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.
# File vendor/rails/actionpack/lib/action_controller/caching.rb, line 96 96: def caches_page(*actions) 97: return unless perform_caching 98: actions.each do |action| 99: class_eval "after_filter { |c| c.cache_page if c.action_name == '#{action}' }" 100: end 101: end
Expires the page that was cached with the path as a key. Example:
expire_page "/lists/show"
# File vendor/rails/actionpack/lib/action_controller/caching.rb, line 75 75: def expire_page(path) 76: return unless perform_caching 77: 78: benchmark "Expired page: #{page_cache_file(path)}" do 79: File.delete(page_cache_path(path)) if File.exists?(page_cache_path(path)) 80: end 81: end