Class: Rack::Response

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

Overview

This file is part of the “Utopia Framework” project, and is licensed under the GNU AGPLv3. Copyright 2010 Samuel Williams. All rights reserved. See <utopia.rb> for licensing details.

Instance Method Summary collapse

Instance Method Details

#cache!(duration = 3600) ⇒ Object



11
12
13
14
15
16
# File 'lib/utopia/extensions/rack.rb', line 11

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

#do_not_cache!Object



6
7
8
9
# File 'lib/utopia/extensions/rack.rb', line 6

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