Class: Rack::Response
- Inherits:
-
Object
- Object
- Rack::Response
- Defined in:
- lib/utopia/extensions/rack.rb
Instance Method Summary collapse
-
#cache!(duration = 3600) ⇒ Object
Specify that the content should be cached.
-
#content_type!(value) ⇒ Object
Specify the content type of the response data.
-
#do_not_cache! ⇒ Object
Specifies that the content shouldn’t be cached.
Instance Method Details
#cache!(duration = 3600) ⇒ Object
Specify that the content should be cached.
36 37 38 39 40 41 |
# File 'lib/utopia/extensions/rack.rb', line 36 def cache!(duration = 3600) unless headers[CACHE_CONTROL] =~ /no-cache/ headers[CACHE_CONTROL] = "public, max-age=#{duration}" headers[EXPIRES] = (Time.now + duration).httpdate end end |
#content_type!(value) ⇒ Object
Specify the content type of the response data.
44 45 46 |
# File 'lib/utopia/extensions/rack.rb', line 44 def content_type!(value) headers[CONTENT_TYPE] = value.to_s end |