Module: ActionDispatch::Http::Cache::Response
- Included in:
- Response
- Defined in:
- lib/action_dispatch/http/cache.rb
Instance Attribute Summary collapse
-
#cache_control ⇒ Object
readonly
Returns the value of attribute cache_control.
Instance Method Summary collapse
- #etag ⇒ Object
- #etag=(etag) ⇒ Object
- #etag? ⇒ Boolean
- #initialize ⇒ Object
- #last_modified ⇒ Object
- #last_modified=(utc_time) ⇒ Object
- #last_modified? ⇒ Boolean
Instance Attribute Details
#cache_control ⇒ Object (readonly)
Returns the value of attribute cache_control.
42 43 44 |
# File 'lib/action_dispatch/http/cache.rb', line 42 def cache_control @cache_control end |
Instance Method Details
#etag ⇒ Object
73 74 75 |
# File 'lib/action_dispatch/http/cache.rb', line 73 def etag @etag end |
#etag=(etag) ⇒ Object
81 82 83 84 |
# File 'lib/action_dispatch/http/cache.rb', line 81 def etag=(etag) key = ActiveSupport::Cache.(etag) @etag = self["ETag"] = %("#{Digest::MD5.hexdigest(key)}") end |
#etag? ⇒ Boolean
77 78 79 |
# File 'lib/action_dispatch/http/cache.rb', line 77 def etag? @etag end |
#initialize ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/action_dispatch/http/cache.rb', line 44 def initialize(*) status, header, body = super @cache_control = {} @etag = self["ETag"] if cache_control = self["Cache-Control"] cache_control.split(/,\s*/).each do |segment| first, last = segment.split("=") last ||= true @cache_control[first.to_sym] = last end end end |
#last_modified ⇒ Object
59 60 61 62 63 |
# File 'lib/action_dispatch/http/cache.rb', line 59 def last_modified if last = headers['Last-Modified'] Time.httpdate(last) end end |
#last_modified=(utc_time) ⇒ Object
69 70 71 |
# File 'lib/action_dispatch/http/cache.rb', line 69 def last_modified=(utc_time) headers['Last-Modified'] = utc_time.httpdate end |
#last_modified? ⇒ Boolean
65 66 67 |
# File 'lib/action_dispatch/http/cache.rb', line 65 def last_modified? headers.include?('Last-Modified') end |