Package org.restlet.data
Class CacheDirective
java.lang.Object
org.restlet.data.CacheDirective
- All Implemented Interfaces:
NamedValue<String>
Directive for caching mechanisms along the call chain. This overrides the
default behavior of those caches and proxies.
Note that when used with HTTP connectors, this class maps to the "Cache-Control" header.
Note that when used with HTTP connectors, this class maps to the "Cache-Control" header.
- Author:
- Jerome Louvel
-
Constructor Summary
ConstructorsConstructorDescriptionCacheDirective(String name) Constructor for directives with no value.CacheDirective(String name, String value) Constructor for directives with a value.CacheDirective(String name, String value, boolean digit) Constructor for directives with a value. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetName()Returns the name.getValue()Returns the value.inthashCode()booleanisDigit()Returns true if the directive contains a digit value.static CacheDirectivemaxAge(int maxAge) Creates a "max-age" directive.static CacheDirectivemaxStale()Creates a "max-stale" directive.static CacheDirectivemaxStale(int maxStale) Creates a "max-stale" directive.static CacheDirectiveminFresh(int minFresh) Creates a "min-fresh" directive.static CacheDirectiveCreates a "must-revalidate" directive.static CacheDirectivenoCache()Creates a "no-cache" directive.static CacheDirectiveCreates a "no-cache" directive.static CacheDirectiveCreates a "no-cache" directive.static CacheDirectivenoStore()Creates a "no-store" directive.static CacheDirectiveCreates a "no-transform" directive.static CacheDirectiveCreates a "onlyIfCached" directive.static CacheDirectiveCreates a "private" directive.static CacheDirectiveprivateInfo(String fieldName) Creates a "private" directive.static CacheDirectiveprivateInfo(List<String> fieldNames) Creates a "private" directive.static CacheDirectiveCreates a "proxy-revalidate" directive.static CacheDirectiveCreates a "public" directive.voidsetDigit(boolean digit) Indicates if the directive is a digit value.voidSets the name.voidSets the value.static CacheDirectivesharedMaxAge(int sharedMaxAge) Creates a "s-maxage" directive.toString()
-
Constructor Details
-
CacheDirective
Constructor for directives with no value.- Parameters:
name- The directive name.
-
CacheDirective
Constructor for directives with a value.- Parameters:
name- The directive name.value- The directive value.
-
CacheDirective
Constructor for directives with a value.- Parameters:
name- The directive name.value- The directive value.digit- The kind of value (true for a digit value, false otherwise).
-
-
Method Details
-
maxAge
Creates a "max-age" directive. Indicates that the client is willing to accept a response whose age is no greater than the specified time in seconds. Unless "max-stale" directive is also included, the client is not willing to accept a stale response.
Note that this directive can be used on requests or responses.- Parameters:
maxAge- Maximum age in seconds.- Returns:
- A new "max-age" directive.
- See Also:
-
maxStale
Creates a "max-stale" directive. Indicates that the client is willing to accept a response that has exceeded its expiration time by any amount of time.
Note that this directive can be used on requests only.- Returns:
- A new "max-stale" directive.
- See Also:
-
maxStale
Creates a "max-stale" directive. Indicates that the client is willing to accept a response that has exceeded its expiration time by a given amount of time.
Note that this directive can be used on requests only.- Parameters:
maxStale- Maximum stale age in seconds.- Returns:
- A new "max-stale" directive.
- See Also:
-
minFresh
Creates a "min-fresh" directive. Indicates that the client is willing to accept a response whose freshness lifetime is no less than its current age plus the specified time in seconds. That is, the client wants a response that will still be fresh for at least the specified number of seconds.
Note that this directive can be used on requests only.- Parameters:
minFresh- Minimum freshness lifetime in seconds.- Returns:
- A new "min-fresh" directive.
- See Also:
-
mustRevalidate
Creates a "must-revalidate" directive. Indicates that the origin server requires revalidation of a cache entry on any subsequent use.
Note that this directive can be used on responses only.- Returns:
- A new "must-revalidate" directive.
- See Also:
-
noCache
Creates a "no-cache" directive. Indicates that a cache must not use the response to satisfy subsequent requests without successful revalidation with the origin server.
Note that this directive can be used on requests or responses.- Returns:
- A new "no-cache" directive.
- See Also:
-
noCache
Creates a "no-cache" directive. Indicates that a cache must not use the response to satisfy subsequent requests without successful revalidation with the origin server.
Note that this directive can be used on requests or responses.- Parameters:
fieldNames- Field names, typically a HTTP header name, that must not be sent by caches.- Returns:
- A new "no-cache" directive.
- See Also:
-
noCache
Creates a "no-cache" directive. Indicates that a cache must not use the response to satisfy subsequent requests without successful revalidation with the origin server.
Note that this directive can be used on requests or responses.- Parameters:
fieldName- A field name, typically a HTTP header name, that must not be sent by caches.- Returns:
- A new "no-cache" directive.
- See Also:
-
noStore
Creates a "no-store" directive. Indicates that a cache must not release or retain any information about the call. This applies to both private and shared caches.
Note that this directive can be used on requests or responses.- Returns:
- A new "no-store" directive.
- See Also:
-
noTransform
Creates a "no-transform" directive. Indicates that a cache or intermediary proxy must not transform the response entity.
Note that this directive can be used on requests or responses.- Returns:
- A new "no-transform" directive.
- See Also:
-
onlyIfCached
Creates a "onlyIfCached" directive. Indicates that only cached responses should be returned to the client.
Note that this directive can be used on requests only.- Returns:
- A new "only-if-cached" directive.
- See Also:
-
privateInfo
Creates a "private" directive. Indicates that all or part of the response message is intended for a single user and must not be cached by a shared cache.
Note that this directive can be used on responses only.- Returns:
- A new "private" directive.
- See Also:
-
privateInfo
Creates a "private" directive. Indicates that all or part of the response message is intended for a single user and must not be cached by a shared cache.
Note that this directive can be used on responses only.- Parameters:
fieldNames- Field names, typically a HTTP header name, that must be private.- Returns:
- A new "private" directive.
- See Also:
-
privateInfo
Creates a "private" directive. Indicates that all or part of the response message is intended for a single user and must not be cached by a shared cache.
Note that this directive can be used on responses only.- Parameters:
fieldName- A field name, typically a HTTP header name, that is private.- Returns:
- A new "private" directive.
- See Also:
-
proxyMustRevalidate
Creates a "proxy-revalidate" directive. Indicates that the origin server requires revalidation of a cache entry on any subsequent use, except that it does not apply to non-shared user agent caches
Note that this directive can be used on responses only.- Returns:
- A new "proxy-revalidate" directive.
- See Also:
-
publicInfo
Creates a "public" directive. Indicates that the response may be cached by any cache, even if it would normally be non-cacheable or cacheable only within a non-shared cache.
Note that this directive can be used on responses only.- Returns:
- A new "public" directive.
- See Also:
-
equals
-
getName
Returns the name.- Specified by:
getNamein interfaceNamedValue<String>- Returns:
- The name.
-
getValue
Returns the value.- Specified by:
getValuein interfaceNamedValue<String>- Returns:
- The value.
-
hashCode
public int hashCode() -
isDigit
public boolean isDigit()Returns true if the directive contains a digit value.- Returns:
- True if the directive contains a digit value.
-
setDigit
public void setDigit(boolean digit) Indicates if the directive is a digit value.- Parameters:
digit- True if the directive contains a digit value.
-
setName
Sets the name.- Parameters:
name- The name.
-
setValue
Sets the value.- Specified by:
setValuein interfaceNamedValue<String>- Parameters:
value- The value.
-
toString
-