Hi Michael,

Fell free to create a jira issue for it and change the code yourself. Then
commit it into svn.

Alin

On Sun, Feb 28, 2010 at 5:31 PM, Michael Szalay <michael.sza...@gmail.com>wrote:

> Hi all
>
> in addition to http://issues.ops4j.org/browse/PAXWEB-174, I have a
> suggestion for another performance improvement.
> Using ETAGs has improved the overall performance my pax web based
> applications dramatically.
> Have a look at the patch...its a very very small change.
>
> Regards Michael
>
>
> Index:
> src/main/java/org/ops4j/pax/web/service/jetty/internal/ResourceServlet.java
> ---
> src/main/java/org/ops4j/pax/web/service/jetty/internal/ResourceServlet.java
> Base (BASE)
> +++
> src/main/java/org/ops4j/pax/web/service/jetty/internal/ResourceServlet.java
> Locally Modified (Based On LOCAL)
> @@ -31,6 +31,10 @@
>     extends HttpServlet
>  {
>
> +    //header constants
> +    private static final String IFNONEMATCH_HEADER = "If-None-Match";
> +    private static final String ETAG = "ETag";
> +
>     private final HttpContext m_httpContext;
>     private final String m_contextName;
>     private final String m_alias;
> @@ -86,6 +90,15 @@
>             return;
>         }
>
> +        //if the request contains an etag and its the same for the
> resource, we deliver a NOT MODIFIED response
> +        String eTag = String.valueOf(resource.hashCode());
> +        if ((request.getHeader(IFNONEMATCH_HEADER) != null) &&
> (eTag.equals(request.getHeader(IFNONEMATCH_HEADER)))) {
> +            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
> +            return;
> +        }
> +        //set the etag
> +        response.setHeader(ETAG, eTag);
> +
>         String mimeType = m_httpContext.getMimeType( mapping );
>         if( mimeType == null )
>         {
>
> _______________________________________________
> general mailing list
> general@lists.ops4j.org
> http://lists.ops4j.org/mailman/listinfo/general
>
>


-- 
Alin Dreghiciu
Software Developer
My profile: http://www.linkedin.com/in/alindreghiciu
My blog: http://adreghiciu.wordpress.com
http://sonatype.com - Sonatype - The Maven Company
http://www.ops4j.org - New Energy for OSS Communities - Open Participation
Software.
http://www.qi4j.org - New Energy for Java - Domain Driven Development.
_______________________________________________
general mailing list
general@lists.ops4j.org
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to