Class Index [+]

Quicksearch

ActionDispatch::Http::Cache::Response

Constants

DEFAULT_CACHE_CONTROL

Attributes

cache_control[R]

Public Class Methods

new(*) click to toggle source
    # File lib/action_dispatch/http/cache.rb, line 44
44:         def initialize(*)
45:           status, header, body = super
46: 
47:           @cache_control = {}
48:           @etag = self["ETag"]
49: 
50:           if cache_control = self["Cache-Control"]
51:             cache_control.split(/,\s*/).each do |segment|
52:               first, last = segment.split("=")
53:               last ||= true
54:               @cache_control[first.to_sym] = last
55:             end
56:           end
57:         end

Public Instance Methods

etag() click to toggle source
    # File lib/action_dispatch/http/cache.rb, line 73
73:         def etag
74:           @etag
75:         end
etag=(etag) click to toggle source
    # File lib/action_dispatch/http/cache.rb, line 81
81:         def etag=(etag)
82:           key = ActiveSupport::Cache.expand_cache_key(etag)
83:           @etag = self["ETag"] = %("#{Digest::MD5.hexdigest(key)}")
84:         end
etag?() click to toggle source
    # File lib/action_dispatch/http/cache.rb, line 77
77:         def etag?
78:           @etag
79:         end
last_modified() click to toggle source
    # File lib/action_dispatch/http/cache.rb, line 59
59:         def last_modified
60:           if last = headers['Last-Modified']
61:             Time.httpdate(last)
62:           end
63:         end
last_modified=(utc_time) click to toggle source
    # File lib/action_dispatch/http/cache.rb, line 69
69:         def last_modified=(utc_time)
70:           headers['Last-Modified'] = utc_time.httpdate
71:         end
last_modified?() click to toggle source
    # File lib/action_dispatch/http/cache.rb, line 65
65:         def last_modified?
66:           headers.include?('Last-Modified')
67:         end

Private Instance Methods

handle_conditional_get!() click to toggle source
     # File lib/action_dispatch/http/cache.rb, line 88
 88:         def handle_conditional_get!
 89:           if etag? || last_modified? || !@cache_control.empty?
 90:             set_conditional_cache_control!
 91:           elsif nonempty_ok_response?
 92:             self.etag = body
 93: 
 94:             if request && request.etag_matches?(etag)
 95:               self.status = 304
 96:               self.body = []
 97:             end
 98: 
 99:             set_conditional_cache_control!
100:           else
101:             headers["Cache-Control"] = "no-cache"
102:           end
103:         end
nonempty_ok_response?() click to toggle source
     # File lib/action_dispatch/http/cache.rb, line 105
105:         def nonempty_ok_response?
106:           @status == 200 && string_body?
107:         end
set_conditional_cache_control!() click to toggle source
     # File lib/action_dispatch/http/cache.rb, line 115
115:         def set_conditional_cache_control!
116:           return if self["Cache-Control"].present?
117: 
118:           control = @cache_control
119: 
120:           if control.empty?
121:             headers["Cache-Control"] = DEFAULT_CACHE_CONTROL
122:           elsif @cache_control[:no_cache]
123:             headers["Cache-Control"] = "no-cache"
124:           else
125:             extras  = control[:extras]
126:             max_age = control[:max_age]
127: 
128:             options = []
129:             options << "max-age=#{max_age.to_i}" if max_age
130:             options << (control[:public] ? "public" : "private")
131:             options << "must-revalidate" if control[:must_revalidate]
132:             options.concat(extras) if extras
133: 
134:             headers["Cache-Control"] = options.join(", ")
135:           end
136:         end
string_body?() click to toggle source
     # File lib/action_dispatch/http/cache.rb, line 109
109:         def string_body?
110:           !@blank && @body.respond_to?(:all?) && @body.all? { |part| part.is_a?(String) }
111:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.