class Rack::AcornCache::Request

Public Class Methods

new(env) click to toggle source
Calls superclass method
# File lib/acorn_cache/request.rb, line 9
def initialize(env)
  super
  @cache_control_header = CacheControlHeader.new(@env["HTTP_CACHE_CONTROL"])
end

Public Instance Methods

cache_key() click to toggle source
# File lib/acorn_cache/request.rb, line 37
def cache_key
  return base_url + path if page_rule? && page_rule[:ignore_query_params]
  url
end
cacheable?() click to toggle source
# File lib/acorn_cache/request.rb, line 29
def cacheable?
  get? && (config.cache_everything || page_rule?)
end
max_age_more_restrictive?(cached_response) click to toggle source
# File lib/acorn_cache/request.rb, line 24
def max_age_more_restrictive?(cached_response)
  cached_response.stale_time_specified? &&
    max_age && max_age < cached_response.time_to_live
end
page_rule() click to toggle source
# File lib/acorn_cache/request.rb, line 33
def page_rule
  @page_rule ||= config.page_rule_for_url(url) if config
end
Also aliased as: page_rule?
page_rule?()
Alias for: page_rule
update_conditional_headers!(cached_response) click to toggle source
# File lib/acorn_cache/request.rb, line 14
def update_conditional_headers!(cached_response)
  if cached_response.etag_header
    self.if_none_match = cached_response.etag_header
  end

  if cached_response.last_modified_header
    self.if_modified_since = cached_response.last_modified_header
  end
end

Private Instance Methods

config() click to toggle source
# File lib/acorn_cache/request.rb, line 46
def config
  Rack::AcornCache.configuration
end
if_modified_since=(last_modified) click to toggle source
# File lib/acorn_cache/request.rb, line 54
def if_modified_since=(last_modified)
  env["HTTP_IF_MODIFIED_SINCE"] = last_modified
end
if_none_match=(etag) click to toggle source
# File lib/acorn_cache/request.rb, line 50
def if_none_match=(etag)
  env["HTTP_IF_NONE_MATCH"] = etag
end