module ActionController::Caching::Pages::ClassMethods
Public Instance Methods
cache_page(content, path, extension = nil, gzip = Zlib::BEST_COMPRESSION)
click to toggle source
Manually cache the content
in the key determined by path
.
cache_page "I'm the cached content", "/lists/show"
# File lib/action_controller/caching/pages.rb, line 193 def cache_page(content, path, extension = nil, gzip = Zlib::BEST_COMPRESSION) if perform_caching page_cache.cache(content, path, extension, gzip) end end
caches_page(*actions)
click to toggle source
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.
You can also pass a :gzip
option to override the class configuration one.
# cache the index action caches_page :index # cache the index action except for JSON requests caches_page :index, if: Proc.new { !request.format.json? } # don't gzip images caches_page :image, gzip: false
# File lib/action_controller/caching/pages.rb, line 213 def caches_page(*actions) if perform_caching options = actions.extract_options! gzip_level = options.fetch(:gzip, page_cache_compression) gzip_level = \ case gzip_level when Symbol Zlib.const_get(gzip_level.upcase) when Integer gzip_level when false nil else Zlib::BEST_COMPRESSION end after_action({ only: actions }.merge(options)) do |c| c.cache_page(nil, nil, gzip_level) end end end
expire_page(path)
click to toggle source
Expires the page that was cached with the path
as a key.
expire_page "/lists/show"
# File lib/action_controller/caching/pages.rb, line 184 def expire_page(path) if perform_caching page_cache.expire(path) end end
Private Instance Methods
page_cache()
click to toggle source
# File lib/action_controller/caching/pages.rb, line 237 def page_cache PageCache.new(page_cache_directory, default_static_extension) end