|Summary:||Proposal : port mod_expires in java as ExpiresFilter Servlet Filter|
|Product:||Tomcat 7||Reporter:||Cyrille Le Clerc <cleclerc>|
|Component:||Catalina||Assignee:||Tomcat Developers Mailing List <dev>|
|OS:||Mac OS X 10.4|
Port of mod_expires as ExpiresFilter
Port of mod_expires as ExpiresFilter with optimized null checks
Description Cyrille Le Clerc 2010-03-26 16:38:18 UTC
Created attachment 25189 [details] Port of mod_expires as ExpiresFilter Here is a proposal to port Apache Httpd mod_expires in java as ExpiresFilter, a standard Servlet Filter. I detailed a standalone version on http://code.google.com/p/xebia-france/wiki/ExpiresFilter . More over, I tried my best to provide very detailed javadocs and docs (in filter.html). The proposed contribution is slightly different because it uses Tomcat logging, few Servlet 3 enhancements and test cases use Tomcat engine. The attached patch contains : * ExpiresFilter.java : the Expires Filter * TestExpiresFilter : detailed test cases * filter.xml : doc updates The filter has been optimized using a profiler and stress tested with Apache Bench under high load.
Comment 1 Cyrille Le Clerc 2010-03-29 18:17:29 UTC
Created attachment 25208 [details] Port of mod_expires as ExpiresFilter with optimized null checks This patch slightly smaller than previous .patch file because the previous .patch file included twice TestExpiresFilter.java. Changes in this patch: * ExpiresFilter.java : reduce null checks for speed optimization, * filter.xml : add a comment in to warn users not to declare blank chars between ';' and 'charset=' for 'ExpiresByType' directives, * TestExpiresFilter.java : narrow the precision interval in cache-control checks.
Comment 2 Sylvain Laurent 2010-03-29 18:40:43 UTC
why not use http://tuckey.org/urlrewrite/ ? it can do this and many other things...
Comment 3 Cyrille Le Clerc 2010-03-29 19:02:39 UTC
(In reply to comment #2) > why not use http://tuckey.org/urlrewrite/ ? it can do this and many other > things... My understanding is that the UrlRewriteFilter can add response headers (e.g. 'Expires' and 'Cache-Control') according to request attributes like a URI pattern (e.g. *.html). However, I don't see how I could express something like "if the response content type is 'application/rss+xml' and if no expiration header has been defined, then add an expiration of 5 minutes". A challenge I see in this kind of feature is to apply the expiration-header-generation logic just before the servlet engine starts to write in the response body in the socket.
Comment 4 Mark Thomas 2010-07-14 18:16:23 UTC
Thanks for the patch. I have applied it to trunk and it will be included in 7.0.1 onwards. I did make a few changes: - fixed various Eclipse warnings - removed the active option