[ http://issues.apache.org/jira/browse/COCOON-1266?page=all ] Antonio Gallardo closed COCOON-1266: ------------------------------------
Fix Version: 2.2-dev (Current SVN) 2.1.10-dev (current SVN) Resolution: Fixed Thanks for the patch. It was applied with minor changes in 2.1.10-dev and 2.2-dev. Please reopen the issue if needed. > [PATCH] Resource reader fails to add HTTP headers > ------------------------------------------------- > > Key: COCOON-1266 > URL: http://issues.apache.org/jira/browse/COCOON-1266 > Project: Cocoon > Type: Bug > Components: - Components: Sitemap > Versions: 2.1.5 > Environment: Operating System: All > Platform: All > Reporter: Martin Kuck > Assignee: Antonio Gallardo > Fix For: 2.2-dev (Current SVN), 2.1.10-dev (current SVN) > > 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 @@ > } > > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira