Class: ActionController::Caching::HttpCache::HttpCacheFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_http_cache.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HttpCacheFilter

Returns a new instance of HttpCacheFilter.



31
32
33
# File 'lib/easy_http_cache.rb', line 31

def initialize(options = {})
  @options = options
end

Instance Method Details

#filter(controller) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/easy_http_cache.rb', line 35

def filter(controller)
  return unless flash.empty? && controller.request.get?

  last_modified = get_last_modified(controller)
  controller.response.last_modified = last_modified if last_modified

  processed_etags = get_processed_etags(controller)
  controller.response.etag = processed_etags if processed_etags

  if controller.request.fresh?(controller.response)
    controller.send(:head, :not_modified)
    return false
  end
end