[opencms-dev] response.setContentType()

Christoph Schönfeld cschoenfeld at sylphen.com
Thu Nov 16 17:18:38 CET 2006


Please notice that delivering image data can impact performance.
OpenCms takes care to send a HTTP 304 (Not Modified) response when 
serving image data. Your JSP would have to do that as well in order to 
not re-deliver an image stream each time the page is called (unless the 
image resource file has changed in VFS).

See the CmsImageLoader class for more information on the topic and 
especially CmsDumpLoader.canSendLastModifiedHeader() which implements 
the 304 sending and finally calls 
HttpServletResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED if not 
modified. CmsImageLoader is a subclass of the last mentioned one.

The schematic implementation is as follow:
1. First call: server sets Last-Modified header in the response along 
with the file data
2. Browser remembers the modification date and
3. sends a Conditional GET with the header "If-Modified-Since"
4. Server responds with HTTP 304 (Not Modified) or goto 1

Also refer to the HTTP specification for more details.

Best regards,
Christoph



More information about the opencms-dev mailing list