Package com.helger.http.cache
Class CacheControlBuilder
java.lang.Object
com.helger.http.cache.CacheControlBuilder
- All Implemented Interfaces:
com.helger.base.clone.ICloneable<CacheControlBuilder>
@NotThreadSafe
public class CacheControlBuilder
extends Object
implements com.helger.base.clone.ICloneable<CacheControlBuilder>
This class is used to build the response HTTP header field Cache-Control value in a structured
way. This header field is only applicable for HTTP/1.1
- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionConstructorCopy constructor -
Method Summary
Modifier and TypeMethodDescriptionaddExtension(String sExtension) com.helger.collection.commons.ICommonsList<String> getClone()booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanisPublic()Set the maximum age relative to the request timesetMaxAgeDays(long nDays) Set the maximum age in days relative to the request timesetMaxAgeHours(long nHours) Set the maximum age in hours relative to the request timesetMaxAgeMinutes(long nMinutes) Set the maximum age in minutes relative to the request timesetMaxAgeSeconds(long nSeconds) Set the maximum age in seconds relative to the request time.setMustRevalidate(boolean bMustRevalidate) Set the must-revalidate value.setNoCache(boolean bNoCache) Set the no-cache value.setNoStore(boolean bNoStore) Set the no-store value.setNoTransform(boolean bNoTransform) Set the no-transform value.setPrivate(boolean bPrivate) Set the private value. allows caches that are specific to one user (e.g., in a browser) to store the response; shared caches (e.g., in a proxy) may not.setProxyRevalidate(boolean bProxyRevalidate) Set the proxy-revalidate value.setPublic(boolean bPublic) Set the public value. marks authenticated responses as cacheable; normally, if HTTP authentication is required, responses are automatically private.setSharedMaxAge(TimeUnit eTimeUnit, long nDuration) Set the maximum age for shared caches relative to the request time.setSharedMaxAgeDays(long nDays) Set the maximum age for shared caches in days relative to the request time.setSharedMaxAgeHours(long nHours) Set the maximum age for shared caches in hours relative to the request time.setSharedMaxAgeMinutes(long nMinutes) Set the maximum age for shared caches in minutes relative to the request time.setSharedMaxAgeSeconds(long nSeconds) Set the maximum age for shared caches in seconds relative to the request time.toString()
-
Constructor Details
-
CacheControlBuilder
public CacheControlBuilder()Constructor -
CacheControlBuilder
Copy constructor- Parameters:
aBase- The object to copy the settings from. May not benull.
-
-
Method Details
-
setMaxAge
Set the maximum age relative to the request time- Parameters:
eTimeUnit-TimeUnitto usenDuration- The duration in the passed unit- Returns:
- this
-
setMaxAgeDays
Set the maximum age in days relative to the request time- Parameters:
nDays- Days to keep it- Returns:
- this
-
setMaxAgeHours
Set the maximum age in hours relative to the request time- Parameters:
nHours- Hours to keep it- Returns:
- this
-
setMaxAgeMinutes
Set the maximum age in minutes relative to the request time- Parameters:
nMinutes- Minutes to keep it- Returns:
- this
-
setMaxAgeSeconds
Set the maximum age in seconds relative to the request time. Specifies the maximum amount of time that a representation will be considered fresh. Similar to Expires, this directive is relative to the time of the request, rather than absolute. [seconds] is the number of seconds from the time of the request you wish the representation to be fresh for.- Parameters:
nSeconds- Seconds to keep it- Returns:
- this
-
hasMaxAgeSeconds
public boolean hasMaxAgeSeconds() -
getMaxAgeSeconds
-
setPublic
Set the public value. marks authenticated responses as cacheable; normally, if HTTP authentication is required, responses are automatically private.- Parameters:
bPublic-trueto enable public- Returns:
- this
-
isPublic
public boolean isPublic() -
setPrivate
Set the private value. allows caches that are specific to one user (e.g., in a browser) to store the response; shared caches (e.g., in a proxy) may not.- Parameters:
bPrivate-trueto enable private- Returns:
- this
-
isPrivate
public boolean isPrivate() -
setNoCache
Set the no-cache value. Forces caches to submit the request to the origin server for validation before releasing a cached copy, every time. This is useful to assure that authentication is respected (in combination with public), or to maintain rigid freshness, without sacrificing all of the benefits of caching.- Parameters:
bNoCache-trueto enable no-cache- Returns:
- this
-
isNoCache
public boolean isNoCache() -
setNoStore
Set the no-store value. Instructs caches not to keep a copy of the representation under any conditions.- Parameters:
bNoStore-trueto enable no-store- Returns:
- this
-
isNoStore
public boolean isNoStore() -
setNoTransform
Set the no-transform value. Implementors of intermediate caches (proxies) have found it useful to convert the media type of certain entity bodies. A non- transparent proxy might, for example, convert between image formats in order to save cache space or to reduce the amount of traffic on a slow link. If a message includes the no-transform directive, an intermediate cache or proxy MUST NOT change those headers that are listed in section 13.5.2 as being subject to the no-transform directive. This implies that the cache or proxy MUST NOT change any aspect of the entity-body that is specified by these headers, including the value of the entity-body itself.- Parameters:
bNoTransform-trueto enable no-transform- Returns:
- this
-
isNoTransform
public boolean isNoTransform() -
setMustRevalidate
Set the must-revalidate value. Tells caches that they must obey any freshness information you give them about a representation. HTTP allows caches to serve stale representations under special conditions; by specifying this header, you’re telling the cache that you want it to strictly follow your rules.- Parameters:
bMustRevalidate-trueto enable must-revalidate- Returns:
- this
-
isMustRevalidate
public boolean isMustRevalidate() -
setProxyRevalidate
Set the proxy-revalidate value. Similar to must-revalidate, except that it only applies to proxy caches.- Parameters:
bProxyRevalidate-trueto enable proxy-revalidate- Returns:
- this
-
isProxyRevalidate
public boolean isProxyRevalidate() -
addExtension
-
getAllExtensions
@Nonnull @ReturnsMutableCopy public com.helger.collection.commons.ICommonsList<String> getAllExtensions() -
getAsHTTPHeaderValue
-
getClone
- Specified by:
getClonein interfacecom.helger.base.clone.ICloneable<CacheControlBuilder>
-
toString
-