net.sf.ehcache.constructs.web.filter
Class GzipFilter
java.lang.Object
net.sf.ehcache.constructs.web.filter.Filter
net.sf.ehcache.constructs.web.filter.GzipFilter
- All Implemented Interfaces:
- javax.servlet.Filter
public class GzipFilter
- extends Filter
Provides GZIP compression of responses.
See the filter-mappings.xml entry for the gzip filter for the URL patterns
which will be gzipped. At present this includes .jsp, .js and .css.
- Version:
- $Id: GzipFilter.java 512 2007-07-10 09:18:45Z gregluck $
- Author:
- Greg Luck, Adam Murdoch
Method Summary |
protected boolean |
acceptsGzipEncoding(javax.servlet.http.HttpServletRequest request)
Determine whether the user agent accepts GZIP encoding. |
protected void |
doDestroy()
A template method that performs any Filter specific destruction tasks. |
protected void |
doFilter(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain)
Performs the filtering for a request. |
protected void |
doInit()
Performs initialisation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GzipFilter
public GzipFilter()
doInit
protected void doInit()
throws java.lang.Exception
- Performs initialisation.
- Specified by:
doInit
in class Filter
- Throws:
java.lang.Exception
doDestroy
protected void doDestroy()
- A template method that performs any Filter specific destruction tasks.
Called from
Filter.destroy()
- Specified by:
doDestroy
in class Filter
doFilter
protected void doFilter(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain chain)
throws java.lang.Exception
- Performs the filtering for a request.
- Specified by:
doFilter
in class Filter
- Throws:
java.lang.Exception
acceptsGzipEncoding
protected boolean acceptsGzipEncoding(javax.servlet.http.HttpServletRequest request)
- Determine whether the user agent accepts GZIP encoding. This feature is part of HTTP1.1.
If a browser accepts GZIP encoding it will advertise this by including in its HTTP header:
Accept-Encoding: gzip
Requests which do not accept GZIP encoding fall into the following categories:
- Old browsers, notably IE 5 on Macintosh.
- Internet Explorer through a proxy. By default HTTP1.1 is enabled but disabled when going
through a proxy. 90% of non gzip requests seen on the Internet are caused by this.
As of September 2004, about 34% of Internet requests do not accept GZIP encoding.
- Overrides:
acceptsGzipEncoding
in class Filter
- Parameters:
request
-
- Returns:
- true, if the User Agent request accepts GZIP encoding