Exemplo n.º 1
0
  /**
   * Sets the last-modified header field and the expires field.
   *
   * @param when
   */
  protected final void setLastModified(Date when) {
    if (when == null) {
      return;
    }

    if (when.before(app().getBootDate())) {
      // last-modified can not be before the Gitblit boot date
      // this helps ensure that pages are properly refreshed after a
      // server config change
      when = app().getBootDate();
    }

    int expires = app().settings().getInteger(Keys.web.pageCacheExpires, 0);
    WebResponse response = (WebResponse) getResponse();
    response.setLastModifiedTime(Time.valueOf(when));
    response.setDateHeader(
        "Expires", System.currentTimeMillis() + Duration.minutes(expires).getMilliseconds());
  }