java.lang.Object
io.jooby.handler.CacheControl
Class allowing the fine tune the browser cache behavior for assets.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CacheControldefaults()Returns the default caching configuration for assets.longReturns the max-age header parameter value.booleanisEtag()Returns whether e-tag support is enabled.booleanReturns whether the handling ofIf-Modified-Sinceheader is enabled.static CacheControlnoCache()Returns a caching configuration for disabling cache completely.setETag(boolean etag) Turn on/off e-tag support.setLastModified(boolean lastModified) Turn on/off handling ofIf-Modified-Sinceheader.setMaxAge(long maxAge) Set cache-control header with the given max-age value.Set cache-control header with the given max-age value.Set cache-control header tono-store, must-revalidate, disables e-tag andIf-Modified-Sinceheader support.
-
Field Details
-
UNDEFINED
public static final int UNDEFINEDConstant for the max-age parameter, when set, noCache-Controlheader is generated.- See Also:
-
NO_CACHE
public static final int NO_CACHEConstant for the max-age parameter, when set, theCache-Controlheader is set tono-store, must-revalidate.- See Also:
-
-
Constructor Details
-
CacheControl
public CacheControl()
-
-
Method Details
-
isEtag
public boolean isEtag()Returns whether e-tag support is enabled.- Returns:
trueif enabled.
-
isLastModified
public boolean isLastModified()Returns whether the handling ofIf-Modified-Sinceheader is enabled.- Returns:
trueif enabled.
-
getMaxAge
public long getMaxAge()Returns the max-age header parameter value.- Returns:
- the max-age header parameter value.
-
setETag
Turn on/off e-tag support.- Parameters:
etag- True for turning on.- Returns:
- This instance.
-
setLastModified
Turn on/off handling ofIf-Modified-Sinceheader.- Parameters:
lastModified- True for turning on. Default is: true.- Returns:
- This instance.
-
setMaxAge
Set cache-control header with the given max-age value. If max-age is greater than 0. -
setMaxAge
Set cache-control header with the given max-age value. If max-age is greater than 0.- Parameters:
maxAge- Max-age value in seconds.- Returns:
- This instance.
-
setNoCache
Set cache-control header tono-store, must-revalidate, disables e-tag andIf-Modified-Sinceheader support.- Returns:
- This instance.
-
defaults
Returns the default caching configuration for assets.- e-tag support: enabled
If-Modified-Sincesupport: enabled- max-age:
UNDEFINED(noCache-Controlheader is generated)
- Returns:
- the default cache configuration.
-
noCache
Returns a caching configuration for disabling cache completely.- e-tag support: disabled
If-Modified-Sincesupport: disabled- max-age:
NO_CACHE(theCache-Controlheader is set tono-store, must-revalidate)
- Returns:
- cache configuration that disables caching.
-