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.



37
38
39
40
41
42
# File 'lib/utopia/extensions/rack.rb', line 37

def cache!(duration = 3600)
	unless (self["Cache-Control"] || "").match(/no-cache/)
		self["Cache-Control"] = "public, max-age=#{duration}"
		self["Expires"] = (Time.now + duration).httpdate
	end
end

#content_type!(value) ⇒ Object

Specify the content type of the response data.



45
46
47
# File 'lib/utopia/extensions/rack.rb', line 45

def content_type!(value)
	self["Content-Type"] = value.to_s
end

#do_not_cache!Object

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



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

def do_not_cache!
	self["Cache-Control"] = "no-cache, must-revalidate"
	self["Expires"] = Time.now.httpdate
end