
public.javadoc.org.spincast.plugins.httpcaching.SpincastCacheHeadersRequestContextAddon.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
SpincastCacheHeadersRequestContextAddon (org.spincast:spincast-framework 1.7.1 API)
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
Modifier and Type
Field and Description
protected static org.slf4j.Logger
logger
-
Constructor Summary
Constructors
Constructor and Description
SpincastCacheHeadersRequestContextAddon(R requestContext,
ETagFactory etagFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
CacheHeadersRequestContextAddon<R>
cache(int seconds)
The number of seconds the client should cache this resource
before requesting it again.
CacheHeadersRequestContextAddon<R>
cache(int seconds,
boolean isPrivate)
The number of seconds the client should cache this resource
before requesting it again.
CacheHeadersRequestContextAddon<R>
cache(int seconds,
boolean isPrivate,
Integer cdnSeconds)
The number of seconds the client should cache this resource
before requesting it again.
CacheHeadersRequestContextAddon<R>
eTag(String currentTag)
Specifies the current ETag (strong) of the resource.
CacheHeadersRequestContextAddon<R>
eTag(String currentTag,
boolean currentTagIsWeak)
Specifies the current strong or weak ETag of the resource.
CacheHeadersRequestContextAddon<R>
eTag(String currentTag,
boolean currentTagIsWeak,
boolean weakComparison)
Specifies the current strong or weak ETag of the resource.
protected String
formatDateForHttpHeader(Date date)
protected Date
getDateFromIfModifiedSinceHeader()
protected Date
getDateFromIfUnmodifiedSinceHeader()
protected ETag
getETag()
protected ETagFactory
getEtagFactory()
List<ETag>
getEtagsFromIfMatchHeader()
List<ETag>
getEtagsFromIfNoneMatchHeader()
protected Object
getExchange()
protected Date
getLastModificationDate()
protected R
getRequestContext()
protected boolean
isEtagMatches(ETag requestETag,
boolean weakComparison)
protected boolean
isEtagsFromIfMatchHeaderContainsAWildcard()
protected boolean
isEtagsFromIfNoneMatchHeaderContainsAWildcard()
protected boolean
isETagWeakComparison()
protected boolean
isIfMatchEtagMatches()
protected boolean
isIfNoneMatchEtagMatches()
CacheHeadersRequestContextAddon<R>
lastModified(Date lastModificationDate)
Specifies the last modification date of the resource.
SpincastCacheHeadersRequestContextAddon<R>
noCache()
Sends "No Cache" headers so the resource is not cached
at all by the client.
protected void
setETag(ETag eTag)
protected void
setETagWeakComparison(boolean eTagWeakComparison)
protected void
setLastModificationDate(Date lastModificationDate)
boolean
validate(boolean resourceCurrentlyExists)
Call this when you are done setting
ETag
and/or Last-Modified
to validate
them agains the headers sent by the client.
-
-
Constructor Detail
-
SpincastCacheHeadersRequestContextAddon
@Inject
public SpincastCacheHeadersRequestContextAddon(R requestContext,
ETagFactory etagFactory)
-
Method Detail
-
getRequestContext
protected R getRequestContext()
-
getEtagFactory
protected ETagFactory getEtagFactory()
-
getExchange
protected Object getExchange()
-
getETag
protected ETag getETag()
-
setETag
protected void setETag(ETag eTag)
-
isETagWeakComparison
protected boolean isETagWeakComparison()
-
setETagWeakComparison
protected void setETagWeakComparison(boolean eTagWeakComparison)
-
getLastModificationDate
protected Date getLastModificationDate()
-
setLastModificationDate
protected void setLastModificationDate(Date lastModificationDate)
-
eTag
public CacheHeadersRequestContextAddon<R> eTag(String currentTag)
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 interface CacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
eTag
public CacheHeadersRequestContextAddon<R> eTag(String currentTag,
boolean currentTagIsWeak)
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 interface CacheHeadersRequestContextAddon<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 interface CacheHeadersRequestContextAddon<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
public CacheHeadersRequestContextAddon<R> lastModified(Date lastModificationDate)
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 interface CacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
isEtagsFromIfMatchHeaderContainsAWildcard
protected boolean isEtagsFromIfMatchHeaderContainsAWildcard()
-
isEtagsFromIfNoneMatchHeaderContainsAWildcard
protected boolean isEtagsFromIfNoneMatchHeaderContainsAWildcard()
-
isIfMatchEtagMatches
protected boolean isIfMatchEtagMatches()
-
isIfNoneMatchEtagMatches
protected boolean isIfNoneMatchEtagMatches()
-
isEtagMatches
protected boolean isEtagMatches(ETag requestETag,
boolean weakComparison)
-
getDateFromIfModifiedSinceHeader
protected Date getDateFromIfModifiedSinceHeader()
-
getDateFromIfUnmodifiedSinceHeader
protected Date getDateFromIfUnmodifiedSinceHeader()
-
cache
public CacheHeadersRequestContextAddon<R> cache(int seconds)
Description copied from interface: CacheHeadersRequestContextAddon
The number of seconds the client should cache this resource
before requesting it again.
- Specified by:
cache
in interface CacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
cache
public CacheHeadersRequestContextAddon<R> cache(int seconds,
boolean isPrivate)
Description copied from interface: CacheHeadersRequestContextAddon
The number of seconds the client should cache this resource
before requesting it again.
- Specified by:
cache
in interface CacheHeadersRequestContextAddon<R extends RequestContext<?>>
isPrivate
- should the cache be 'private'?
(help)
-
cache
public CacheHeadersRequestContextAddon<R> cache(int seconds,
boolean isPrivate,
Integer cdnSeconds)
Description copied from interface: CacheHeadersRequestContextAddon
The number of seconds the client should cache this resource
before requesting it again.
- Specified by:
cache
in interface CacheHeadersRequestContextAddon<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. If null
, it
won't be used.
-
noCache
public SpincastCacheHeadersRequestContextAddon<R> 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 interface CacheHeadersRequestContextAddon<R extends RequestContext<?>>
-
validate
public boolean validate(boolean resourceCurrentlyExists)
Description copied from interface: CacheHeadersRequestContextAddon
Call this when you are done setting
ETag
and/or Last-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 interface CacheHeadersRequestContextAddon<R extends RequestContext<?>>
- Parameters:
resourceCurrentlyExists
- Does the resource currently exist?
Copyright © 2019. All rights reserved.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy