code: protected void setResponseHeaders(
          HttpServletRequest request,
          HttpServletResponse response,
          String filename,
          URL resourceURL) {
  
          String cacheControl = "public, max-age=0, must-revalidate";
          int resourceCacheTime = getCacheTime(filename);
          if (resourceCacheTime > 0) {
              cacheControl = "max-age=" + String.valueOf(resourceCacheTime);
          }
          response.setHeader("Cache-Control", cacheControl);
          response.setDateHeader("Expires", System.currentTimeMillis() + (resourceCacheTime * 1000));
  
          // Find the modification timestamp
          long lastModifiedTime = 0;
          URLConnection connection = null;
          try {
              connection = resourceURL.openConnection();
              lastModifiedTime = connection.getLastModified();
              // Remove milliseconds to avoid comparison problems (milliseconds
              // are not returned by the browser in the "If-Modified-Since"
              // header).
              lastModifiedTime = lastModifiedTime - (lastModifiedTime % 1000);
              response.setDateHeader("Last-Modified", lastModifiedTime);
  
              if (browserHasNewestVersion(request, lastModifiedTime)) {
                  response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                  return;
              }
          } catch (Exception e) {
              // Failed to find out last modified timestamp. Continue without it.
              LOG.debug("Failed to find out last modified timestamp. Continuing without it.", e);
          } finally {
              try {
                  if (connection != null) {
                      // Explicitly close the input stream to prevent it
                      // from remaining hanging
                      // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4257700
                      InputStream is = connection.getInputStream();
                      if (is != null) {
                          is.close();
                      }
                  }
              } catch (Exception e) {
                  LOG.info("Error closing URLConnection input stream", e);
              }
          }
  
          // Set type mime type if we can determine it based on the filename
          String mimetype = OpenCms.getResourceManager().getMimeType(filename, "UTF-8");
          if (mimetype != null) {
              response.setContentType(mimetype);
          }
      }
docs: Sets the response headers.<p>
  
  @param request the request
  @param response the response
  @param filename the file name
  @param resourceURL the resource URL