code: public void onBeforeWriteResponseBody(HttpServletRequest request, XHttpServletResponse response) {
  
          if (!isEligibleToExpirationHeaderGeneration(request, response)) {
              return;
          }
  
          Date expirationDate = getExpirationDate(request, response);
          if (expirationDate == null) {
              if (logger.isDebugEnabled()) {
                  logger.debug("Request '{}' with response status '{}' content-type '{}', no expiration configured", new Object[] {
                          request.getRequestURI(), response.getStatus(), response.getContentType() });
              }
          } else {
              if (logger.isDebugEnabled()) {
                  logger.debug("Request '{}' with response status '{}' content-type '{}', set expiration date {}", new Object[] {
                          request.getRequestURI(), response.getStatus(), response.getContentType(), expirationDate });
              }
  
              String maxAgeDirective = "max-age=" + ((expirationDate.getTime() - System.currentTimeMillis()) / 1000);
  
              String cacheControlHeader = response.getCacheControlHeader();
              String newCacheControlHeader = (cacheControlHeader == null) ? maxAgeDirective : cacheControlHeader + ", " + maxAgeDirective;
              response.setHeader(HEADER_CACHE_CONTROL, newCacheControlHeader);
              response.setDateHeader(HEADER_EXPIRES, expirationDate.getTime());
          }
  
      }
docs: <p>
  If no expiration header has been set by the servlet and an expiration has
  been defined in the {@link ExpiresFilter} configuration, sets the '
  <tt>Expires</tt>' header and the attribute '<tt>max-age</tt>' of the '
  <tt>Cache-Control</tt>' header.
  </p>
  <p>
  Must be called on the "Start Write Response Body" event.
  </p>
  <p>
  Invocations to <tt>Logger.debug(...)</tt> are guarded by
  {@link Logger#isDebugEnabled()} because
  {@link HttpServletRequest#getRequestURI()} and
  {@link HttpServletResponse#getContentType()} costs <tt>String</tt>
  objects instantiations (as of Tomcat 7).
  </p>