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
AContainerResponseFilterthat adds Cache-Control headers to allGETresponses.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIG_HTTP_CACHE_MAX_AGEThe configuration key for setting a cache-control max-age header.static StringCONFIG_HTTP_CACHE_NOCACHEThe configuration key for setting a cache-control no-cache header.static StringCONFIG_HTTP_CACHE_REVALIDATEThe 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 voidfilter(ContainerRequestContext req, ContainerResponseContext res)voidsetMaxAge(int maxAge)Set the cache age.voidsetMustRevalidate(boolean mustRevalidate)Set the revalidate flag.voidsetNoCache(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:
filterin interfaceContainerResponseFilter
-
-