Module: Restfulie::Server::ActionController::Trait::Cacheable

Included in:
RestfulResponder
Defined in:
lib/restfulie/server/action_controller/trait/cacheable.rb

Instance Method Summary collapse

Instance Method Details

#cachesObject



64
65
66
# File 'lib/restfulie/server/action_controller/trait/cacheable.rb', line 64

def caches
  [::Expires.new, ::LastModifieds.new]
end

#to_formatObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/restfulie/server/action_controller/trait/cacheable.rb', line 46

def to_format

  cache_request()

  if is_cached?
    set_public_cache_control(headers)
    controller.response.headers["Cache-Control"] = headers.join(', ')
    fresh = request.fresh?(controller.response)
    if fresh
      head :not_modified
    else
      super
    end
  else
    super
  end
end