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) ⇒ 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

#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