Package com.linecorp.armeria.common
Class ServerCacheControl
- java.lang.Object
-
- com.linecorp.armeria.common.CacheControl
-
- com.linecorp.armeria.common.ServerCacheControl
-
public final class ServerCacheControl extends CacheControl
Directives for HTTP caching mechanisms in responses.
-
-
Field Summary
Fields Modifier and Type Field Description static ServerCacheControl
DISABLED
"no-cache, no-store, must-revalidate"
.static ServerCacheControl
EMPTY
An empty instance with all directives disabled.static ServerCacheControl
IMMUTABLE
"max-age=31536000, public, immutable"
.static ServerCacheControl
REVALIDATED
"no-cache, must-revalidate"
.
-
Method Summary
Modifier and Type Method Description String
asHeaderValue()
Encodes the directives in thisCacheControl
into an HTTP"cache-control"
header value.static ServerCacheControlBuilder
builder()
Returns a newly createdServerCacheControlBuilder
with all directives disabled initially.boolean
cachePrivate()
Returns whether the"private"
directive is enabled.boolean
cachePublic()
Returns whether the"public"
directive is enabled.boolean
equals(Object o)
int
hashCode()
boolean
immutable()
Returns whether the"immutable"
directive is enabled.boolean
isEmpty()
Returnstrue
if all directives are disabled.boolean
mustRevalidate()
Returns whether the"must-revalidate"
directive is enabled.static ServerCacheControl
parse(Iterable<String> directives)
Parses the specified"cache-control"
header values into aServerCacheControl
.static ServerCacheControl
parse(String... directives)
Parses the specified"cache-control"
header values into aServerCacheControl
.boolean
proxyRevalidate()
Returns whether the"proxy-revalidate"
directive is enabled.long
sMaxAgeSeconds()
Returns the value of the"s-maxage"
directive or-1
if disabled.ServerCacheControlBuilder
toBuilder()
Returns a newly createdServerCacheControlBuilder
which has the same initial directives with thisServerCacheControl
.-
Methods inherited from class com.linecorp.armeria.common.CacheControl
maxAgeSeconds, noCache, noStore, noTransform, toString
-
-
-
-
Field Detail
-
EMPTY
public static final ServerCacheControl EMPTY
An empty instance with all directives disabled.
-
DISABLED
public static final ServerCacheControl DISABLED
"no-cache, no-store, must-revalidate"
.
-
REVALIDATED
public static final ServerCacheControl REVALIDATED
"no-cache, must-revalidate"
.
-
IMMUTABLE
public static final ServerCacheControl IMMUTABLE
"max-age=31536000, public, immutable"
.
-
-
Method Detail
-
parse
public static ServerCacheControl parse(String... directives)
Parses the specified"cache-control"
header values into aServerCacheControl
. Note that any unknown directives will be ignored.- Returns:
- the
ServerCacheControl
decoded from the specified header values.
-
parse
public static ServerCacheControl parse(Iterable<String> directives)
Parses the specified"cache-control"
header values into aServerCacheControl
. Note that any unknown directives will be ignored.- Returns:
- the
ServerCacheControl
decoded from the specified header values.
-
builder
public static ServerCacheControlBuilder builder()
Returns a newly createdServerCacheControlBuilder
with all directives disabled initially.
-
isEmpty
public boolean isEmpty()
Description copied from class:CacheControl
Returnstrue
if all directives are disabled.- Overrides:
isEmpty
in classCacheControl
-
cachePublic
public boolean cachePublic()
Returns whether the"public"
directive is enabled.
-
cachePrivate
public boolean cachePrivate()
Returns whether the"private"
directive is enabled.
-
immutable
public boolean immutable()
Returns whether the"immutable"
directive is enabled.
-
mustRevalidate
public boolean mustRevalidate()
Returns whether the"must-revalidate"
directive is enabled.
-
proxyRevalidate
public boolean proxyRevalidate()
Returns whether the"proxy-revalidate"
directive is enabled.
-
sMaxAgeSeconds
public long sMaxAgeSeconds()
Returns the value of the"s-maxage"
directive or-1
if disabled.
-
toBuilder
public ServerCacheControlBuilder toBuilder()
Returns a newly createdServerCacheControlBuilder
which has the same initial directives with thisServerCacheControl
.- Specified by:
toBuilder
in classCacheControl
-
asHeaderValue
public String asHeaderValue()
Description copied from class:CacheControl
Encodes the directives in thisCacheControl
into an HTTP"cache-control"
header value.- Specified by:
asHeaderValue
in classCacheControl
- Returns:
- the
"cache-control"
header value, or an empty string if no directives were enabled.
-
equals
public boolean equals(@Nullable Object o)
- Overrides:
equals
in classCacheControl
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classCacheControl
-
-