|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.caucho.filters.AnonymousExpiresFilter
public class AnonymousExpiresFilter
Caches the servlet output for anonymous users. This filter adds an Expires header and the Cache-Control: x-anonymous header.
Requests from anonymous users, i.e. users with no JSESSIONID cookie or ;jsessionid= URL-rewriting, will be cached. So logged-in users will have customized pages, but anonymous users will see a cached page. Since there are generally more anonymous users, using the AnonymousExpiresFilter can dramatically improve performance without losing the ability to customize pages.
Pages should call request.getSession(false)
to get their
sessions, because a page that creates a session will not be cached.
For the same reason, JSP pages would set
<jsp:directive.page session='false'/>
.
The cache-time init-parameter configures how long the page should be cached:
<filter> <filter-name>anonymous-cache</filter-name> <filter-class>com.caucho.http.filter.AnonymousExpiresFilter</filter-class> <init-param cache-time='10s'/> </filter>The cache-time allows the standard extensions:
s | seconds |
m | minutes |
h | hours |
D | days |
W | weeks |
M | months |
Y | years |
Constructor Summary | |
---|---|
AnonymousExpiresFilter()
|
Method Summary | |
---|---|
void |
destroy()
Any cleanup for the filter. |
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain nextFilter)
The filter add an Expires time in the future and adds the x-anonymous Cache-Control directive. |
void |
init(FilterConfig config)
Filter init reads the filter configuration |
void |
setCacheTime(Period period)
Sets the file cache time. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnonymousExpiresFilter()
Method Detail |
---|
public void setCacheTime(Period period)
public void init(FilterConfig config) throws ServletException
init
in interface Filter
ServletException
public void doFilter(ServletRequest request, ServletResponse response, FilterChain nextFilter) throws ServletException, java.io.IOException
doFilter
in interface Filter
request
- the servlet requestresponse
- the servlet responsenextFilter
- the next filter in the chain
ServletException
java.io.IOException
public void destroy()
destroy
in interface Filter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |