public class CacheControl extends Object
AssetHandler
,
AssetHandler.cacheControl(Function)
Modifier and Type | Field and Description |
---|---|
static int |
NO_CACHE
Constant for the max-age parameter, when set, the
Cache-Control header is set to no-store, must-revalidate . |
static int |
UNDEFINED
Constant for the max-age parameter, when set, no
Cache-Control header is generated. |
Constructor and Description |
---|
CacheControl() |
Modifier and Type | Method and Description |
---|---|
static CacheControl |
defaults()
Returns the default caching configuration for assets.
|
long |
getMaxAge()
Returns the max-age header parameter value.
|
boolean |
isEtag()
Returns whether e-tag support is enabled.
|
boolean |
isLastModified()
Returns whether the handling of
If-Modified-Since header is enabled. |
static CacheControl |
noCache()
Returns a caching configuration for disabling cache completely.
|
CacheControl |
setETag(boolean etag)
Turn on/off e-tag support.
|
CacheControl |
setLastModified(boolean lastModified)
Turn on/off handling of
If-Modified-Since header. |
CacheControl |
setMaxAge(Duration maxAge)
Set cache-control header with the given max-age value.
|
CacheControl |
setMaxAge(long maxAge)
Set cache-control header with the given max-age value.
|
CacheControl |
setNoCache()
Set cache-control header to
no-store, must-revalidate , disables e-tag
and If-Modified-Since header support. |
public static final int UNDEFINED
Cache-Control
header is generated.setMaxAge(long)
,
Constant Field Valuespublic static final int NO_CACHE
Cache-Control
header is set to no-store, must-revalidate
.setMaxAge(long)
,
Constant Field Valuespublic boolean isEtag()
true
if enabled.public boolean isLastModified()
If-Modified-Since
header is enabled.true
if enabled.public long getMaxAge()
public CacheControl setETag(boolean etag)
etag
- True for turning on.public CacheControl setLastModified(boolean lastModified)
If-Modified-Since
header.lastModified
- True for turning on. Default is: true.public CacheControl setMaxAge(long maxAge)
public CacheControl setMaxAge(Duration maxAge)
maxAge
- Max-age value in seconds.public CacheControl setNoCache()
no-store, must-revalidate
, disables e-tag
and If-Modified-Since
header support.public static CacheControl defaults()
If-Modified-Since
support: enabledUNDEFINED
(no Cache-Control
header is generated)public static CacheControl noCache()
If-Modified-Since
support: disabledNO_CACHE
(the Cache-Control
header is set to no-store, must-revalidate
)Copyright © 2020. All rights reserved.