public class CacheHeaders
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static boolean |
hasCacheHeader(javax.servlet.http.HttpServletResponse res) |
static void |
setCacheable(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
long age,
java.util.concurrent.TimeUnit unit)
Permit caching the response for up to the age specified.
|
static void |
setCacheable(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
long age,
java.util.concurrent.TimeUnit unit,
boolean mustRevalidate)
Permit caching the response for up to the age specified.
|
static void |
setCacheablePrivate(javax.servlet.http.HttpServletResponse res,
long age,
java.util.concurrent.TimeUnit unit,
boolean mustRevalidate)
Allow the response to be cached only by the user-agent.
|
static void |
setCacheablePublic(javax.servlet.http.HttpServletResponse res,
long age,
java.util.concurrent.TimeUnit unit,
boolean mustRevalidate)
Allow the response to be cached by proxies and user-agents.
|
static void |
setNotCacheable(javax.servlet.http.HttpServletResponse res)
Do not cache the response, anywhere.
|
public static void setNotCacheable(javax.servlet.http.HttpServletResponse res)
res
- response being returned.public static void setCacheable(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, long age, java.util.concurrent.TimeUnit unit)
If the request is on a secure connection (e.g. SSL) private caching is used. This allows the user-agent to cache the response, but requests intermediate proxies to not cache. This may offer better protection for Set-Cookie headers.
If the request is on plaintext (insecure), public caching is used. This may allow an intermediate proxy to cache the response, including any Set-Cookie header that may have also been included.
req
- current request.res
- response being returned.age
- how long the response can be cached.unit
- time unit for age, usually TimeUnit.SECONDS
.public static void setCacheable(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, long age, java.util.concurrent.TimeUnit unit, boolean mustRevalidate)
If the request is on a secure connection (e.g. SSL) private caching is used. This allows the user-agent to cache the response, but requests intermediate proxies to not cache. This may offer better protection for Set-Cookie headers.
If the request is on plaintext (insecure), public caching is used. This may allow an intermediate proxy to cache the response, including any Set-Cookie header that may have also been included.
req
- current request.res
- response being returned.age
- how long the response can be cached.unit
- time unit for age, usually TimeUnit.SECONDS
.mustRevalidate
- true if the client must validate the cached entity.public static void setCacheablePublic(javax.servlet.http.HttpServletResponse res, long age, java.util.concurrent.TimeUnit unit, boolean mustRevalidate)
If the response includes a Set-Cookie header the cookie may be cached by a proxy and returned to multiple browsers behind the same proxy. This is insecure for authenticated connections.
res
- response being returned.age
- how long the response can be cached.unit
- time unit for age, usually TimeUnit.SECONDS
.mustRevalidate
- true if the client must validate the cached entity.public static void setCacheablePrivate(javax.servlet.http.HttpServletResponse res, long age, java.util.concurrent.TimeUnit unit, boolean mustRevalidate)
res
- response being returned.age
- how long the response can be cached.unit
- time unit for age, usually TimeUnit.SECONDS
.mustRevalidate
- true if the client must validate the cached entity.public static boolean hasCacheHeader(javax.servlet.http.HttpServletResponse res)