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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSpincastCacheHeadersRequestContextAddon(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 StringformatDateForHttpHeader(Date date) protected Dateprotected Dateprotected ETaggetETag()protected ETagFactoryprotected Objectprotected Dateprotected Rprotected booleanisEtagMatches(ETag requestETag, boolean weakComparison) protected booleanprotected booleanprotected booleanprotected booleanprotected booleanlastModified(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 voidprotected voidsetETagWeakComparison(boolean eTagWeakComparison) protected voidsetLastModificationDate(Date lastModificationDate) booleanvalidate(boolean resourceCurrentlyExists) Call this when you are done settingETagand/orLast-Modifiedto 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:CacheHeadersRequestContextAddonSpecifies 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
nullif the resource doesn't exist.- Specified by:
eTagin interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
eTag
Description copied from interface:CacheHeadersRequestContextAddonSpecifies 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
nullif the resource doesn't exist.- Specified by:
eTagin interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
eTag
public CacheHeadersRequestContextAddon<R> eTag(String currentTag, boolean currentTagIsWeak, boolean weakComparison) Description copied from interface:CacheHeadersRequestContextAddonSpecifies the current strong or weak ETag of the resource.Skip, or use
nullif the resource doesn't exist.- Specified by:
eTagin 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:CacheHeadersRequestContextAddonSpecifies the last modification date of the resource.Skip, or use
nullif the resource doesn't exist.- Specified by:
lastModifiedin 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:CacheHeadersRequestContextAddonThe number of seconds the client should cache this resource before requesting it again.- Specified by:
cachein interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
cache
Description copied from interface:CacheHeadersRequestContextAddonThe number of seconds the client should cache this resource before requesting it again.- Specified by:
cachein interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>isPrivate- should the cache be 'private'? (help)
-
cache
Description copied from interface:CacheHeadersRequestContextAddonThe number of seconds the client should cache this resource before requesting it again.- Specified by:
cachein 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:CacheHeadersRequestContextAddonSends "No Cache" headers so the resource is not cached at all by the client.- Specified by:
noCachein interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
validate
public boolean validate(boolean resourceCurrentlyExists) Description copied from interface:CacheHeadersRequestContextAddonCall this when you are done settingETagand/orLast-Modifiedto 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:
validatein interfaceCacheHeadersRequestContextAddon<R extends RequestContext<?>>- Parameters:
resourceCurrentlyExists- Does the resource currently exist?
-