Module: ActionController::Caching::HttpCache::ClassMethods

Defined in:
lib/easy_http_cache.rb

Instance Method Summary collapse

Instance Method Details

#http_cache(*actions) ⇒ Object

Declares that actions should be cached.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/easy_http_cache.rb', line 11

def http_cache(*actions)
  return unless perform_caching
  options = actions.extract_options!

  options.assert_valid_keys(
    :last_modified, :method, :etag, :if, :unless
  )

  http_cache_filter = HttpCacheFilter.new(
    :method => options.delete(:method),
    :last_modified => [options.delete(:last_modified)].flatten.compact,
    :etag => options.delete(:etag)
  )
  filter_options = {:only => actions}.merge(options)

  before_filter(http_cache_filter, filter_options)
end