Class LastModifiedHandler

java.lang.Object
com.atlassian.plugin.servlet.util.LastModifiedHandler

public class LastModifiedHandler extends Object
This class manages the last modified date of a single HTTP resource.
  • Constructor Details

    • LastModifiedHandler

      public LastModifiedHandler()
    • LastModifiedHandler

      public LastModifiedHandler(@Nullable LocalDateTime lastModifiedDate)
    • LastModifiedHandler

      public LastModifiedHandler(@Nullable Date lastModifiedDate)
  • Method Details

    • checkRequest

      @Deprecated public static boolean checkRequest(@Nonnull jakarta.servlet.http.HttpServletRequest request, @Nonnull jakarta.servlet.http.HttpServletResponse response, @Nonnull Date lastModifiedDate)
      Deprecated.

      In the future the method isNotCacheableResponse(HttpServletRequest) should be used for the check for a better naming convention.

      This static method is used when the resource being served by the servlet keeps track of the last modified date, and so no state needs to be maintained by this handler.

      See Also:
    • setCacheHeadersIfCacheable

      public static void setCacheHeadersIfCacheable(@Nonnull jakarta.servlet.http.HttpServletRequest request, @Nonnull jakarta.servlet.http.HttpServletResponse response, @Nonnull LocalDateTime lastModifiedDate)
    • checkRequest

      @Deprecated public boolean checkRequest(@Nonnull jakarta.servlet.http.HttpServletRequest request, @Nonnull jakarta.servlet.http.HttpServletResponse response)
      Deprecated.
      This method performs two operations, which is setting the response headers and checking the cache headers.

      In the future the method isNotCacheableResponse(HttpServletRequest) should be used for the check.

      In the future the method setCacheHeadersIfCacheable(HttpServletRequest, HttpServletResponse) should be used to defined the response headers.

      Check whether we need to generate a response for this request.

      Set the necessary headers on the response, and if we don't need to provide content, set the response status to 304.

      If this method returns true, the caller should not perform any more processing on the request.

      Parameters:
      request - The request with the caching headers used for the verification.
      response - The response with the content used to generate the ETag.
      Returns:
      true if we don't need to provide any data to satisfy this request.
    • isNotCacheableResponse

      public boolean isNotCacheableResponse(@Nonnull jakarta.servlet.http.HttpServletRequest request)

      Verifies whether the current response is cacheable or not, based on the HttpServletRequest and isCacheEnabled().

      Parameters:
      request - The request with the caching headers used for the verification.
      Returns:

      true: If the current defined response is not cacheable.

      false: If the current defined response is cacheable.

    • setCacheHeadersIfCacheable

      public void setCacheHeadersIfCacheable(@Nonnull jakarta.servlet.http.HttpServletRequest request, @Nonnull jakarta.servlet.http.HttpServletResponse response)
      Defines the caching headers for the current HttpServletResponse if it is a isNotCacheableResponse(jakarta.servlet.http.HttpServletRequest).
    • modified

      public void modified()
      The content has changed, reset the modified date.