|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.oscache.web.filter.CacheFilter
public class CacheFilter
CacheFilter is a filter that allows for server-side caching of post-processed servlet content.
It also gives great programatic control over refreshing, flushing and updating the cache.
Field Summary | |
---|---|
static long |
EXPIRES_OFF
|
static long |
EXPIRES_ON
|
static long |
EXPIRES_TIME
|
static int |
FRAGMENT_AUTODETECT
|
static int |
FRAGMENT_NO
|
static int |
FRAGMENT_YES
|
static String |
HEADER_ACCEPT_ENCODING
|
static String |
HEADER_CACHE_CONTROL
|
static String |
HEADER_CONTENT_ENCODING
|
static String |
HEADER_CONTENT_TYPE
|
static String |
HEADER_EXPIRES
|
static String |
HEADER_IF_MODIFIED_SINCE
|
static String |
HEADER_LAST_MODIFIED
|
static long |
LAST_MODIFIED_INITIAL
|
static long |
LAST_MODIFIED_OFF
|
static long |
LAST_MODIFIED_ON
|
static int |
NOCACHE_OFF
|
static int |
NOCACHE_SESSION_ID_IN_URL
|
Constructor Summary | |
---|---|
CacheFilter()
|
Method Summary | |
---|---|
protected boolean |
acceptsGZipEncoding(javax.servlet.http.HttpServletRequest request)
Check if the client browser support gzip compression. |
String[] |
createCacheGroups(javax.servlet.http.HttpServletRequest httpRequest,
ServletCacheAdministrator scAdmin,
Cache cache)
Creates the cache groups for the CacheFilter. |
String |
createCacheKey(javax.servlet.http.HttpServletRequest httpRequest,
ServletCacheAdministrator scAdmin,
Cache cache)
Creates the cache key for the CacheFilter. |
void |
destroy()
Filter clean-up |
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
The doFilter call caches the response by wrapping the HttpServletResponse
object so that the output stream can be caught. |
void |
init(javax.servlet.FilterConfig filterConfig)
Initialize the filter. |
protected boolean |
isCacheable(CacheHttpServletResponseWrapper cacheResponse)
isCacheable is a method allowing subclass to decide if a response is cachable or not. |
protected boolean |
isCacheable(javax.servlet.ServletRequest request)
isCacheable is a method allowing a subclass to decide if a request is cachable or not. |
protected boolean |
isFilteredBefore(javax.servlet.ServletRequest request)
Checks if the request was filtered before, so guarantees to be executed once per request. |
protected boolean |
isFragment(javax.servlet.http.HttpServletRequest request)
Checks if the request is a fragment in a page. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String HEADER_LAST_MODIFIED
public static final String HEADER_CONTENT_TYPE
public static final String HEADER_CONTENT_ENCODING
public static final String HEADER_EXPIRES
public static final String HEADER_IF_MODIFIED_SINCE
public static final String HEADER_CACHE_CONTROL
public static final String HEADER_ACCEPT_ENCODING
public static final int FRAGMENT_AUTODETECT
public static final int FRAGMENT_NO
public static final int FRAGMENT_YES
public static final int NOCACHE_OFF
public static final int NOCACHE_SESSION_ID_IN_URL
public static final long LAST_MODIFIED_OFF
public static final long LAST_MODIFIED_ON
public static final long LAST_MODIFIED_INITIAL
public static final long EXPIRES_OFF
public static final long EXPIRES_ON
public static final long EXPIRES_TIME
Constructor Detail |
---|
public CacheFilter()
Method Detail |
---|
public void destroy()
destroy
in interface javax.servlet.Filter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws javax.servlet.ServletException, IOException
HttpServletResponse
object so that the output stream can be caught. This works by splitting off the output
stream into two with the SplitServletOutputStream
class. One stream gets written
out to the response as normal, the other is fed into a byte array inside a ResponseContent
object.
doFilter
in interface javax.servlet.Filter
request
- The servlet requestresponse
- The servlet responsechain
- The filter chain
javax.servlet.ServletException
- IOException
IOException
public void init(javax.servlet.FilterConfig filterConfig)
ServletCacheAdministrator
instance and configures the filter based on any initialization parameters.The supported initialization parameters are:
application
(default), session
, request
and
page
.auto
(default) for auto detect, no
and yes
.off
(default) and sessionIdInURL
if the session id is
contained in the URL.off
for don't sending the header, even it is set in the filter chain,
on
for sending it if it is set in the filter chain and
inital
(default) the last modified information will be set based on the current time and changes are allowed.off
for don't sending the header, even it is set in the filter chain,
on
(default) for sending it if it is set in the filter chain and
time
the expires information will be intialized based on the time parameter and creation time of the content.ICacheKeyProvider
.
A developer can implement a method which provides cache keys based on the request,
the servlect cache administrator and cache.ICacheGroupsProvider
.
A developer can implement a method which provides cache groups based on the request,
the servlect cache administrator and cache.
init
in interface javax.servlet.Filter
filterConfig
- The filter configurationpublic String createCacheKey(javax.servlet.http.HttpServletRequest httpRequest, ServletCacheAdministrator scAdmin, Cache cache)
ICacheKeyProvider
createCacheKey
in interface ICacheKeyProvider
httpRequest
- the http request.scAdmin
- the ServletCacheAdministrator of the cachecache
- the cache of the ServletCacheAdministrator
ICacheKeyProvider.createCacheKey(javax.servlet.http.HttpServletRequest, ServletCacheAdministrator, Cache)
public String[] createCacheGroups(javax.servlet.http.HttpServletRequest httpRequest, ServletCacheAdministrator scAdmin, Cache cache)
ICacheGroupsProvider
createCacheGroups
in interface ICacheGroupsProvider
httpRequest
- the http request.scAdmin
- the ServletCacheAdministrator of the cachecache
- the cache of the ServletCacheAdministrator
ICacheGroupsProvider.createCacheGroups(javax.servlet.http.HttpServletRequest, ServletCacheAdministrator, Cache)
protected boolean isFragment(javax.servlet.http.HttpServletRequest request)
javax.servlet.include.request_uri
is set.
According to Java Servlet API 2.3 this is excepted for servlets obtained
by using the getNamedDispatcher method.
request
- the to be handled request
protected boolean isFilteredBefore(javax.servlet.ServletRequest request)
request
- checks if the request was filtered before.
protected boolean isCacheable(javax.servlet.ServletRequest request)
request
- The servlet request
protected boolean isCacheable(CacheHttpServletResponseWrapper cacheResponse)
cacheResponse
- The HTTP servlet response
protected boolean acceptsGZipEncoding(javax.servlet.http.HttpServletRequest request)
request
- the http request
|
OSCache Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |