You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Dustin Callaway <DC...@hfnweb.com> on 2000/01/18 19:58:58 UTC
Problem with setting the Last-Modified HTTP header...
I've run into a problem with Tomcat setting the Last-Modified HTTP header.
The service() method of the HttpServer class doesn't seem to set the
Last-Modified header unless the browser issued a conditional GET (included
an If-Modified-Since header). However, as far as I know, the Last-Modified
header should be returned regardless (even for non-conditional GETs) so the
browser has a date to use when issuing a conditional GET in the future. A
portion of the code from the service() method of HttpServer looks like this:
if (ifModifiedSince == -1) {
// if the client didn't ask for a if-modifed-since
// no need to go further -- just do it.
doGet(req, resp);
} else {
// this is the most expensive path through
// but we know we need to do it at this point
maybeSetLastModified(resp, lastModified);
long now = System.currentTimeMillis();
if (now < ifModifiedSince || ifModifiedSince < lastModified) {
doGet(req, resp);
}
Notice that requests that do not contain an If-Modified-Since header will
not receive a Last-Modified header in the response (Last-Modified is set in
the maybeSetLastModified() method). Is this a bug or can someone tell me why
it should behave this way?
Thanks!
Dustin Callaway
(callaway@sourcestream.com)