DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=31243>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=31243 Resource reader fails to add HTTP headers Summary: Resource reader fails to add HTTP headers Product: Cocoon 2 Version: 2.1.5 Platform: All OS/Version: All Status: NEW Severity: Normal Priority: Other Component: sitemap components AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] The resource reader does not add Last-Modified and Expires headers when serving resources from the cocoon cache. This leads to unneccessary request from clients. I think setting the headers in setup() instead of generate() should fix this problem because generate will only be called for resources not already in the cache. Fixing this will trigger another bug introduced with patch #14048. This causes all resources to be deliverd with a Vary:Host header unless an expiration time has been set on the reader (which you usually won´t do). This causes IE to read the resource again and again. The correct solution is to add an Expires header with a value of 0, but only if configured! I prepared a small patch (against 2.1.5) to fix both problems: diff -u -r1.1.1.3 -r1.5 --- ResourceReader.java 10 Jun 2004 11:23:49 -0000 1.1.1.3 +++ ResourceReader.java 10 Jun 2004 12:36:49 -0000 1.5 @@ -118,6 +118,15 @@ try { inputSource = resolver.resolveURI(src); + + if (expires >= 0) { + response.setDateHeader("Expires", expires > 0 ? System.currentTimeMillis() + expires : 0); + } + + long lastModified = getLastModified(); + if (lastModified > 0) { + response.setDateHeader("Last-Modified", lastModified); + } } catch (SourceException se) { throw SourceUtil.handle("Error during resolving of '" + src + "'.", se); @@ -255,18 +264,6 @@ */ public void generate() throws IOException, ProcessingException { try { - if (expires > 0) { - response.setDateHeader("Expires", System.currentTimeMillis() + expires); - } - else { - response.addHeader("Vary", "Host"); - } - - long lastModified = getLastModified(); - if (lastModified > 0) { - response.setDateHeader("Last-Modified", lastModified); - } - try { inputStream = inputSource.getInputStream(); } @@ -316,3 +313,4 @@ } }
