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.
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.
why not use http://tuckey.org/urlrewrite/ ? it can do this and many other things...
(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.
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