Class: Rack::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia/extensions/rack.rb

Instance Method Summary collapse

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_typeObject



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

#do_not_cache!Object

Specifies that the content shouldn’t be cached. Overrides cache! if already called.



30
31
32
33
# File 'lib/utopia/extensions/rack.rb', line 30

def do_not_cache!
  headers[CACHE_CONTROL] = "no-cache, must-revalidate"
  headers[EXPIRES] = Time.now.httpdate
end