Package com.linecorp.armeria.common
Class CacheControl
- java.lang.Object
-
- com.linecorp.armeria.common.CacheControl
-
- Direct Known Subclasses:
ClientCacheControl
,ServerCacheControl
public abstract class CacheControl extends Object
Directives for HTTP caching mechanisms in requests or responses. UseServerCacheControl
for response-side andClientCacheControl
for request-side.- See Also:
CacheControlBuilder
, Cache-Control (MDN)
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CacheControl(boolean noCache, boolean noStore, boolean noTransform, long maxAgeSeconds)
Creates a new instance with the specified directives.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract String
asHeaderValue()
Encodes the directives in thisCacheControl
into an HTTP"cache-control"
header value.boolean
equals(Object o)
int
hashCode()
boolean
isEmpty()
Returnstrue
if all directives are disabled.long
maxAgeSeconds()
Returns the value of the"max-age"
directive or-1
if disabled.protected StringBuilder
newHeaderValueBuffer()
Returns a newStringBuilder
with the common directives appended.boolean
noCache()
Returns whether the"no-cache"
directive is enabled.boolean
noStore()
Returns whether the"no-store"
directive is enabled.boolean
noTransform()
Returns whether the"no-transform"
directive is enabled.abstract CacheControlBuilder<?>
toBuilder()
Returns a newly createdCacheControlBuilder
which has the same initial directives with thisCacheControl
.String
toString()
-
-
-
Constructor Detail
-
CacheControl
protected CacheControl(boolean noCache, boolean noStore, boolean noTransform, long maxAgeSeconds)
Creates a new instance with the specified directives.- Parameters:
noCache
- whether the"no-cache"
directive is enabled.noStore
- whether the"no-store"
directive is enabled.noTransform
- whether the"no-transform"
directive is enabled.maxAgeSeconds
- the value of the"max-age"
directive, or-1
if disabled.
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Returnstrue
if all directives are disabled.
-
noCache
public final boolean noCache()
Returns whether the"no-cache"
directive is enabled.
-
noStore
public final boolean noStore()
Returns whether the"no-store"
directive is enabled.
-
noTransform
public final boolean noTransform()
Returns whether the"no-transform"
directive is enabled.
-
maxAgeSeconds
public final long maxAgeSeconds()
Returns the value of the"max-age"
directive or-1
if disabled.
-
toBuilder
public abstract CacheControlBuilder<?> toBuilder()
Returns a newly createdCacheControlBuilder
which has the same initial directives with thisCacheControl
.
-
asHeaderValue
public abstract String asHeaderValue()
Encodes the directives in thisCacheControl
into an HTTP"cache-control"
header value.- Returns:
- the
"cache-control"
header value, or an empty string if no directives were enabled.
-
newHeaderValueBuffer
protected final StringBuilder newHeaderValueBuffer()
Returns a newStringBuilder
with the common directives appended. Note that the first two characters (", "
must be stripped.
-
-