java.lang.Object
io.jooby.handler.CacheControl
Class allowing the fine tune the browser cache behavior for assets.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CacheControl
defaults()
Returns the default caching configuration for assets.long
Returns the max-age header parameter value.boolean
isEtag()
Returns whether e-tag support is enabled.boolean
Returns whether the handling ofIf-Modified-Since
header is enabled.static CacheControl
noCache()
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-Since
header.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-Since
header support.
-
Field Details
-
UNDEFINED
public static final int UNDEFINEDConstant for the max-age parameter, when set, noCache-Control
header is generated.- See Also:
-
NO_CACHE
public static final int NO_CACHEConstant for the max-age parameter, when set, theCache-Control
header 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:
true
if enabled.
-
isLastModified
public boolean isLastModified()Returns whether the handling ofIf-Modified-Since
header is enabled.- Returns:
true
if 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-Since
header.- 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-Since
header support.- Returns:
- This instance.
-
defaults
Returns the default caching configuration for assets.- e-tag support: enabled
If-Modified-Since
support: enabled- max-age:
UNDEFINED
(noCache-Control
header is generated)
- Returns:
- the default cache configuration.
-
noCache
Returns a caching configuration for disabling cache completely.- e-tag support: disabled
If-Modified-Since
support: disabled- max-age:
NO_CACHE
(theCache-Control
header is set tono-store, must-revalidate
)
- Returns:
- cache configuration that disables caching.
-