Class: HTTP::Cache::Headers

### Home Classes Methods

### In Files

- lib/http/cache/headers.rb

### Parent

SimpleDelegator

### Methods

- ::new
- #forces_revalidation?
- #max_age
- #must_revalidate?
- #no_cache?
- #no_store?
- #private?
- #public?
- #vary_star?

### Class/Module Index

Quicksearch

- HTTP
- HTTP::Cache
- HTTP::Cache::Headers
- HTTP::Cache::NullCache
- HTTP::Cache::NullLogger
- HTTP::CacheError
- HTTP::Chainable
- HTTP::Client
- HTTP::Connection
- HTTP::Error
- HTTP::Headers
- HTTP::Headers::Mixin
- HTTP::InvalidHeaderNameError
- HTTP::MimeType
- HTTP::MimeType::Adapter
- HTTP::MimeType::JSON
- HTTP::Options
- HTTP::Redirector
- HTTP::Redirector::EndlessRedirectError
- HTTP::Redirector::TooManyRedirectsError
- HTTP::Request
- HTTP::Request::Caching
- HTTP::Request::UnsupportedMethodError
- HTTP::Request::UnsupportedSchemeError
- HTTP::Request::Writer
- HTTP::RequestError
- HTTP::Response
- HTTP::Response::Body
- HTTP::Response::Caching
- HTTP::Response::IoBody
- HTTP::Response::Parser
- HTTP::Response::Status
- HTTP::Response::StringBody
- HTTP::ResponseError
- HTTP::StateError
- HTTP::Timeout
- HTTP::Timeout::Global
- HTTP::Timeout::Null
- HTTP::Timeout::PerOperation
- HTTP::TimeoutError
- HTTP::URI
- Object

No matching classes.

# HTTP::Cache::Headers

Convenience methods around cache control headers.

### Public Class Methods

new(headers) click to toggle source

    # File lib/http/cache/headers.rb, line 10
    def initialize(headers)
      if headers.is_a? HTTP::Headers
        super headers
      else
        super HTTP::Headers.coerce headers
      end
    end

### Public Instance Methods

forces_revalidation?() click to toggle source

@return [Boolean] does this message force revalidation

    # File lib/http/cache/headers.rb, line 19
    def forces_revalidation?
      must_revalidate? || max_age == 0
    end

max_age() click to toggle source

@return [Numeric] the max number of seconds this message is considered fresh.

    # File lib/http/cache/headers.rb, line 50
    def max_age
      explicit_max_age || seconds_til_expires || Float::INFINITY
    end

must_revalidate?() click to toggle source

@return [Boolean] does the cache control include 'must-revalidate'

    # File lib/http/cache/headers.rb, line 24
    def must_revalidate?
      matches?(/\bmust-revalidate\b/)
    end

no_cache?() click to toggle source

@return [Boolean] does the cache control include 'no-cache'

    # File lib/http/cache/headers.rb, line 29
    def no_cache?
      matches?(/\bno-cache\b/)
    end

no_store?() click to toggle source

@return [Boolean] does the cache control include 'no-stor'

    # File lib/http/cache/headers.rb, line 34
    def no_store?
      matches?(/\bno-store\b/)
    end

private?() click to toggle source

@return [Boolean] does the cache control include 'private'

    # File lib/http/cache/headers.rb, line 44
    def private?
      matches?(/\bprivate\b/)
    end

public?() click to toggle source

@return [Boolean] does the cache control include 'public'

    # File lib/http/cache/headers.rb, line 39
    def public?
      matches?(/\bpublic\b/)
    end

vary_star?() click to toggle source

@return [Boolean] is the vary header set to '*'

    # File lib/http/cache/headers.rb, line 55
    def vary_star?
      get(HTTP::Headers::VARY).any? { |v| "*" == v.strip }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.