Package org.trellisldp.http
Class CacheControlFilter
- java.lang.Object
-
- org.trellisldp.http.CacheControlFilter
-
- All Implemented Interfaces:
ContainerResponseFilter
@Provider public class CacheControlFilter extends Object implements ContainerResponseFilter
AContainerResponseFilter
that adds Cache-Control headers to allGET
responses.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIG_HTTP_CACHE_MAX_AGE
The configuration key for setting a cache-control max-age header.static String
CONFIG_HTTP_CACHE_NOCACHE
The configuration key for setting a cache-control no-cache header.static String
CONFIG_HTTP_CACHE_REVALIDATE
The configuration key for setting a cache-control must-revalidate header.
-
Constructor Summary
Constructors Constructor Description CacheControlFilter()
Create a CacheControl decorator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
filter(ContainerRequestContext req, ContainerResponseContext res)
void
setMaxAge(int maxAge)
Set the cache age.void
setMustRevalidate(boolean mustRevalidate)
Set the revalidate flag.void
setNoCache(boolean noCache)
Set the no-cache flag.
-
-
-
Field Detail
-
CONFIG_HTTP_CACHE_MAX_AGE
public static final String CONFIG_HTTP_CACHE_MAX_AGE
The configuration key for setting a cache-control max-age header.- See Also:
- Constant Field Values
-
CONFIG_HTTP_CACHE_REVALIDATE
public static final String CONFIG_HTTP_CACHE_REVALIDATE
The configuration key for setting a cache-control must-revalidate header.- See Also:
- Constant Field Values
-
CONFIG_HTTP_CACHE_NOCACHE
public static final String CONFIG_HTTP_CACHE_NOCACHE
The configuration key for setting a cache-control no-cache header.- See Also:
- Constant Field Values
-
-
Method Detail
-
setMaxAge
public void setMaxAge(int maxAge)
Set the cache age.- Parameters:
maxAge
- the cache age in seconds
-
setMustRevalidate
public void setMustRevalidate(boolean mustRevalidate)
Set the revalidate flag.- Parameters:
mustRevalidate
- true if cliens must revalidate
-
setNoCache
public void setNoCache(boolean noCache)
Set the no-cache flag.- Parameters:
noCache
- true if the no-cache flag is to be returned
-
filter
public void filter(ContainerRequestContext req, ContainerResponseContext res)
- Specified by:
filter
in interfaceContainerResponseFilter
-
-