Utopia SourceUtopiaContentResponse

class Response

A basic content response, including useful defaults for typical HTML5 content.

Definitions

def do_not_cache!

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

Implementation

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

def cache!(duration = 3600, access: "public")

Specify that the content could be cached.

Implementation

def cache!(duration = 3600, access: "public")
	unless cache_control = @headers[CACHE_CONTROL] and cache_control.include?(NO_CACHE)
		@headers[CACHE_CONTROL] = "#{access}, max-age=#{duration}"
		@headers[EXPIRES] = (Time.now + duration).httpdate
	end
end

def content_type= value

Specify the content type of the response data.

Implementation

def content_type= value
	@headers[CONTENT_TYPE] = value
end