Package org.spincast.plugins.httpcaching
Class SpincastCacheHeadersRequestContextAddon<R extends RequestContext<?>>
java.lang.Object
org.spincast.plugins.httpcaching.SpincastCacheHeadersRequestContextAddon<R>
- All Implemented Interfaces:
CacheHeadersRequestContextAddon<R>
public class SpincastCacheHeadersRequestContextAddon<R extends RequestContext<?>>
extends Object
implements CacheHeadersRequestContextAddon<R>
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSpincastCacheHeadersRequestContextAddon
(R requestContext, ETagFactory etagFactory) -
Method Summary
Modifier and TypeMethodDescriptioncache
(int seconds) The number of seconds the client should cache this resource before requesting it again.cache
(int seconds, boolean isPrivate) The number of seconds the client should cache this resource before requesting it again.The number of seconds the client should cache this resource before requesting it again.Specifies the current ETag (strong) of the resource.Specifies the current strong or weak ETag of the resource.Specifies the current strong or weak ETag of the resource.protected String
formatDateForHttpHeader
(Date date) protected Date
protected Date
protected ETag
getETag()
protected ETagFactory
protected Object
protected Date
protected R
protected boolean
isEtagMatches
(ETag requestETag, boolean weakComparison) protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
lastModified
(Date lastModificationDate) Specifies the last modification date of the resource.noCache()
Sends "No Cache" headers so the resource is not cached at all by the client.protected void
protected void
setETagWeakComparison
(boolean eTagWeakComparison) protected void
setLastModificationDate
(Date lastModificationDate) boolean
validate
(boolean resourceCurrentlyExists) Call this when you are done settingETag
and/orLast-Modified
to validate them agains the headers sent by the client.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Details
-
SpincastCacheHeadersRequestContextAddon
-
-
Method Details
-
getRequestContext
-
getEtagFactory
-
getExchange
-
getETag
-
setETag
-
isETagWeakComparison
protected boolean isETagWeakComparison() -
setETagWeakComparison
protected void setETagWeakComparison(boolean eTagWeakComparison) -
getLastModificationDate
-
setLastModificationDate
-
eTag
Description copied from interface:CacheHeadersRequestContextAddon
Specifies the current ETag (strong) of the resource.A strong comparison will be used to compare the request ETag to this current ETag.
Skip, or use
null
if the resource doesn't exist.- Specified by:
eTag
in interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
eTag
Description copied from interface:CacheHeadersRequestContextAddon
Specifies the current strong or weak ETag of the resource.A strong comparison will be used to compare the request ETag to this current ETag.
Skip, or use
null
if the resource doesn't exist.- Specified by:
eTag
in interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
eTag
public CacheHeadersRequestContextAddon<R> eTag(String currentTag, boolean currentTagIsWeak, boolean weakComparison) Description copied from interface:CacheHeadersRequestContextAddon
Specifies the current strong or weak ETag of the resource.Skip, or use
null
if the resource doesn't exist.- Specified by:
eTag
in interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
weakComparison
- should a weak comparison be used instead of a strong one to compare the request ETag to the current ETag?
-
lastModified
Description copied from interface:CacheHeadersRequestContextAddon
Specifies the last modification date of the resource.Skip, or use
null
if the resource doesn't exist.- Specified by:
lastModified
in interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
isEtagsFromIfMatchHeaderContainsAWildcard
protected boolean isEtagsFromIfMatchHeaderContainsAWildcard() -
getEtagsFromIfMatchHeader
-
getEtagsFromIfNoneMatchHeader
-
isEtagsFromIfNoneMatchHeaderContainsAWildcard
protected boolean isEtagsFromIfNoneMatchHeaderContainsAWildcard() -
isIfMatchEtagMatches
protected boolean isIfMatchEtagMatches() -
isIfNoneMatchEtagMatches
protected boolean isIfNoneMatchEtagMatches() -
isEtagMatches
-
getDateFromIfModifiedSinceHeader
-
getDateFromIfUnmodifiedSinceHeader
-
formatDateForHttpHeader
-
cache
Description copied from interface:CacheHeadersRequestContextAddon
The number of seconds the client should cache this resource before requesting it again.- Specified by:
cache
in interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
cache
Description copied from interface:CacheHeadersRequestContextAddon
The number of seconds the client should cache this resource before requesting it again.- Specified by:
cache
in interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
isPrivate
- should the cache be 'private'? (help)
-
cache
Description copied from interface:CacheHeadersRequestContextAddon
The number of seconds the client should cache this resource before requesting it again.- Specified by:
cache
in interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
isPrivate
- should the cache be 'private'? (help)cdnSeconds
- The number of seconds the resource associated with this route should be cached by a CDN/proxy. Ifnull
, it won't be used.
-
noCache
Description copied from interface:CacheHeadersRequestContextAddon
Sends "No Cache" headers so the resource is not cached at all by the client.- Specified by:
noCache
in interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
validate
public boolean validate(boolean resourceCurrentlyExists) Description copied from interface:CacheHeadersRequestContextAddon
Call this when you are done settingETag
and/orLast-Modified
to validate them agains the headers sent by the client.If this method returns
true
, the route handler should return immediately without returning/creating/modifying/deleting the associated resource! Appropriate headers have already been set on the response.- Specified by:
validate
in interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
- Parameters:
resourceCurrentlyExists
- Does the resource currently exist?
-