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