Class: Rack::Response
- Inherits:
-
Object
- Object
- Rack::Response
- Defined in:
- lib/utopia/extensions/rack.rb
Instance Method Summary collapse
-
#cache!(duration = 3600, access = "public") ⇒ Object
Specify that the content should be cached.
- #content_type ⇒ Object
-
#content_type!(value) ⇒ Object
Specify the content type of the response data.
- #content_type=(value) ⇒ Object
-
#do_not_cache! ⇒ Object
Specifies that the content shouldn’t be cached.
Instance Method Details
#cache!(duration = 3600, access = "public") ⇒ 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, access = "public") unless headers[CACHE_CONTROL] =~ /no-cache/ headers[CACHE_CONTROL] = "#{access}, max-age=#{duration}" headers[EXPIRES] = (Time.now + duration).httpdate end end |
#content_type ⇒ Object
52 53 54 |
# File 'lib/utopia/extensions/rack.rb', line 52 def content_type headers[CONTENT_TYPE] 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) self.content_type = value end |
#content_type=(value) ⇒ Object
48 49 50 |
# File 'lib/utopia/extensions/rack.rb', line 48 def content_type= value headers[CONTENT_TYPE] = value end |