Module: Responders::HttpCacheResponder

Defined in:
lib/responders/http_cache_responder.rb

Overview

Set HTTP Last-Modified headers based on the given resource. It's used only on API behavior (to_format) and is useful for a client to check in the server if a resource changed after a specific date or not.

This is not usually not used in html requests because pages contains a lot information besides the resource information, as current_user, flash messages, widgets… that are better handled with other strategies, as fragment caches and the digest of the body.

Instance Method Summary collapse

Instance Method Details

#initialize(controller, resources, options = {}) ⇒ Object


12
13
14
15
# File 'lib/responders/http_cache_responder.rb', line 12

def initialize(controller, resources, options={})
  super
  @http_cache = options.delete(:http_cache)
end

#to_formatObject


17
18
19
20
# File 'lib/responders/http_cache_responder.rb', line 17

def to_format
  return if do_http_cache? && do_http_cache!
  super
end