Class LastModifiedHandler
-
Constructor Summary
ConstructorsConstructorDescriptionLastModifiedHandler(LocalDateTime lastModifiedDate) LastModifiedHandler(Date lastModifiedDate) -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Deprecated.This method performs two operations, which is setting the response headers and checking the cache headers.static booleancheckRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Date lastModifiedDate) Deprecated.In the future the methodisNotCacheableResponse(HttpServletRequest)should be used for the check for a better naming convention.booleanisNotCacheableResponse(jakarta.servlet.http.HttpServletRequest request) Verifies whether the current response is cacheable or not, based on theHttpServletRequestandisCacheEnabled().voidmodified()The content has changed, reset the modified date.voidsetCacheHeadersIfCacheable(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Defines the caching headers for the currentHttpServletResponseif it is aisNotCacheableResponse(jakarta.servlet.http.HttpServletRequest).static voidsetCacheHeadersIfCacheable(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, LocalDateTime lastModifiedDate)
-
Constructor Details
-
LastModifiedHandler
public LastModifiedHandler() -
LastModifiedHandler
-
LastModifiedHandler
-
-
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
HttpServletRequestandisCacheEnabled().- 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 currentHttpServletResponseif it is aisNotCacheableResponse(jakarta.servlet.http.HttpServletRequest). -
modified
public void modified()The content has changed, reset the modified date.
-