Class: Protocol::HTTP::Header::CacheControl

Inherits:
Split
  • Object
show all
Defined in:
lib/protocol/http/header/cache_control.rb

Constant Summary collapse

PRIVATE =
'private'
PUBLIC =
'public'
NO_CACHE =
'no-cache'
NO_STORE =
'no-store'
MAX_AGE =
'max-age'
S_MAXAGE =
's-maxage'
STATIC =
'static'
DYNAMIC =
'dynamic'
STREAMING =
'streaming'
MUST_REVALIDATE =
'must-revalidate'
PROXY_REVALIDATE =
'proxy-revalidate'

Constants inherited from Split

Split::COMMA

Instance Method Summary collapse

Methods inherited from Split

#to_s

Constructor Details

#initialize(value = nil) ⇒ CacheControl

Returns a new instance of CacheControl.



27
28
29
# File 'lib/protocol/http/header/cache_control.rb', line 27

def initialize(value = nil)
  super(value&.downcase)
end

Instance Method Details

#<<(value) ⇒ Object



31
32
33
# File 'lib/protocol/http/header/cache_control.rb', line 31

def << value
  super(value.downcase)
end

#dynamic?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/protocol/http/header/cache_control.rb', line 39

def dynamic?
  self.include?(DYNAMIC)
end

#max_ageObject

The maximum time, in seconds, a response should be considered fresh. See www.rfc-editor.org/rfc/rfc9111.html#name-max-age-2



77
78
79
# File 'lib/protocol/http/header/cache_control.rb', line 77

def max_age
  find_integer_value(MAX_AGE)
end

#must_revalidate?Boolean

Indicates that a response must not be used once it is stale. See www.rfc-editor.org/rfc/rfc9111.html#name-must-revalidate

Returns:

  • (Boolean)


65
66
67
# File 'lib/protocol/http/header/cache_control.rb', line 65

def must_revalidate?
  self.include?(MUST_REVALIDATE)
end

#no_cache?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/protocol/http/header/cache_control.rb', line 55

def no_cache?
  self.include?(NO_CACHE)
end

#no_store?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/protocol/http/header/cache_control.rb', line 59

def no_store?
  self.include?(NO_STORE)
end

#private?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/protocol/http/header/cache_control.rb', line 47

def private?
  self.include?(PRIVATE)
end

#proxy_revalidate?Boolean

Like must-revalidate, but for shared caches only. See www.rfc-editor.org/rfc/rfc9111.html#name-proxy-revalidate

Returns:

  • (Boolean)


71
72
73
# File 'lib/protocol/http/header/cache_control.rb', line 71

def proxy_revalidate?
  self.include?(PROXY_REVALIDATE)
end

#public?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/protocol/http/header/cache_control.rb', line 51

def public?
  self.include?(PUBLIC)
end

#s_maxageObject

Like max-age, but for shared caches only, which should use it before max-age when present. See www.rfc-editor.org/rfc/rfc9111.html#name-s-maxage



84
85
86
# File 'lib/protocol/http/header/cache_control.rb', line 84

def s_maxage
  find_integer_value(S_MAXAGE)
end

#static?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/protocol/http/header/cache_control.rb', line 35

def static?
  self.include?(STATIC)
end

#streaming?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/protocol/http/header/cache_control.rb', line 43

def streaming?
  self.include?(STREAMING)
end