Interface CacheControl
-
public interface CacheControlTheCacheControlinterface represents cache settings for a piece of markup. The settings are only valid for the current request.- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringgetETag()Returns the ETag for the current response that is used as validation tag, ornullif no ETag is set on the response.intgetExpirationTime()Get the currently set expiration time.booleanisPublicScope()Returns a boolean indicating whether the caching scope is set to public for the current response.voidsetETag(String token)Sets an ETag for the current response that is used as validation tag.voidsetExpirationTime(int time)Sets a new expiration time for the current response in seconds.voidsetPublicScope(boolean publicScope)Sets the caching scope for the current response to public withtrueaspublicScopeand to private withfalseaspublicScope.voidsetUseCachedContent(boolean useCachedContent)Sets the indication whether the cached content for the provided ETag at the request is still valid or not.booleanuseCachedContent()Returns a boolean indicating whether the cached content for the provided ETag at the request can still be considerated valid.
-
-
-
Method Detail
-
getExpirationTime
int getExpirationTime()
Get the currently set expiration time. If no expiration time has been explicitly set on this response, the default defined in the portlet deployment descriptor with theexpiration-cachetag is returned; If no default value is provided in the portlet deployment descriptor, 0 is returned.This call returns the same value as the
getProperty(EXPIRATION_CACHE)call.- Returns:
- the currently set expiration time in seconds; 0 indicates caching is disabled for this portlet; -1 indicates the cache does not expire.
-
setExpirationTime
void setExpirationTime(int time)
Sets a new expiration time for the current response in seconds.If the expiration value is set to 0, caching is disabled for this portlet; if the value is set to -1, the cache does not expire.
This call is equivalent to calling
setProperty(EXPIRATION_CACHE).- Parameters:
time- expiration time in seconds
-
isPublicScope
boolean isPublicScope()
Returns a boolean indicating whether the caching scope is set to public for the current response. If no caching scope is set on this response, the default defined in the deployment descriptor with thecache-scopetag is returned, orfalseif no default is defined.Public cache scope indicates that the cache entry can be shared across users. Non-public, or private cache scope indicates that the cache entry must not be shared across users.
This call is equivalent to calling
getProperty(CACHE_SCOPE).equals(PUBLIC_SCOPE).- Returns:
- true if the cache scope is public for the current response.
-
setPublicScope
void setPublicScope(boolean publicScope)
Sets the caching scope for the current response to public withtrueaspublicScopeand to private withfalseaspublicScope.Public cache scope indicates that the cache entry can be shared across users. Non-public, or private cache scope indicates that the cache entry must not be shared across users.
This call is equivalent to calling
(publicScope ? setProperty(CACHE_SCOPE, PUBLIC_SCOPE | setProperty(CACHE_SCOPE, PRIVATE_SCOPE).- Parameters:
publicScope- indicating if the cache entry can be shared across users
-
getETag
String getETag()
Returns the ETag for the current response that is used as validation tag, ornullif no ETag is set on the response.This call is equivalent to calling
getProperty(ETAG).- Returns:
- the ETag for the current response that is
used as validation tag, or
nullif no ETag is set.
-
setETag
void setETag(String token)
Sets an ETag for the current response that is used as validation tag. If an ETag was already set it is replaced with the new value.This call is equivalent to calling
setProperty(ETAG, token).Setting the ETag to
nullremoves the currently set ETag.- Parameters:
token- the ETag token
-
useCachedContent
boolean useCachedContent()
Returns a boolean indicating whether the cached content for the provided ETag at the request can still be considerated valid. If not set, the default isfalse.This call is equivalent to calling
getProperty(USE_CACHED_CONTENT)and getting a non-null value back.- Returns:
- boolean indicating whether the caching scope is set to public for the current response
-
setUseCachedContent
void setUseCachedContent(boolean useCachedContent)
Sets the indication whether the cached content for the provided ETag at the request is still valid or not. If set totrueno output should be rendered, but a new expiration time should be set for the markup with the given ETag .This call is equivalent to calling
setProperty(USE_CACHED_CONTENT, "true").- Parameters:
useCachedContent- boolean indication whether the the cached content is still valid or not
-
-