Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-15003

Max-age value for binaries is higher for older assets

    XMLWordPrintable

Details

    • Flagged
    • Orion
    • Ready for refinement

    Description

      #setExpiresHeaders method inĀ org.hippoecm.hst.servlet.utils.HeaderUtils.setExpiresHeaders(HttpServletResponse response, BinaryPage page) calculates the max-age for binaries value based on the last modified date. It seems that newly uploaded images will get a low value, while older images will get very high numbers over a few years.

      Also can we make max-age configurable?

          public static void setExpiresHeaders(HttpServletResponse response, BinaryPage page) {
              final long lastModifiedDate = page.getLastModified();
              if (lastModifiedDate > 0) {
                  final long expires = System.currentTimeMillis() - lastModifiedDate;
                  if (expires > 0) {
                      response.setDateHeader(HTTP_EXPIRES_HEADER, expires + System.currentTimeMillis());
                      HstRequestContext requestContext = RequestContextProvider.get();
                      boolean isPreview = requestContext != null && requestContext.isPreview();
                      response.setHeader(HTTP_CACHE_CONTROL_HEADER,
                              (isPreview ? CACHE_CONTROL_PRIVATE : CACHE_CONTROL_PUBLIC) +
                                      ", max-age=" + (expires / MILLIS_IN_SEC));
                  }
              }
          }
      

      So why the expires = System.currentTimeMillis() - lastModifiedDate?

      Attachments

        Activity

          People

            deniz.ergun Deniz Ergun
            nannam Nithin Annam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: