Class CacheControlHandlerInterceptor

  • All Implemented Interfaces:
    org.springframework.web.servlet.AsyncHandlerInterceptor, org.springframework.web.servlet.HandlerInterceptor

    public class CacheControlHandlerInterceptor
    extends java.lang.Object
    implements org.springframework.web.servlet.AsyncHandlerInterceptor
    Handler interceptor that adds a Cache-Control header to the response based on @link{CacheControl} annotation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String createCacheControlHeaderField​(CacheControl cacheAnnotation)  
      protected CacheControl getCacheControlAnnotation​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler)  
      protected boolean isEligibleForCacheControl​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler)
      Indicates whether the given request and response are eligible for Cache-Control generation.
      boolean preHandle​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.springframework.web.servlet.AsyncHandlerInterceptor

        afterConcurrentHandlingStarted
      • Methods inherited from interface org.springframework.web.servlet.HandlerInterceptor

        afterCompletion, postHandle
    • Constructor Detail

      • CacheControlHandlerInterceptor

        public CacheControlHandlerInterceptor()
    • Method Detail

      • preHandle

        public final boolean preHandle​(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response,
                                       java.lang.Object handler)
                                throws java.lang.Exception
        Specified by:
        preHandle in interface org.springframework.web.servlet.HandlerInterceptor
        Throws:
        java.lang.Exception
      • isEligibleForCacheControl

        protected boolean isEligibleForCacheControl​(javax.servlet.http.HttpServletRequest request,
                                                    javax.servlet.http.HttpServletResponse response,
                                                    java.lang.Object handler)
        Indicates whether the given request and response are eligible for Cache-Control generation.
        Parameters:
        request - the HTTP request
        response - the HTTP response
        handler - handler (or HandlerMethod)
        Returns:
        true if eligible; false otherwise
      • getCacheControlAnnotation

        protected CacheControl getCacheControlAnnotation​(javax.servlet.http.HttpServletRequest request,
                                                         javax.servlet.http.HttpServletResponse response,
                                                         java.lang.Object handler)
      • createCacheControlHeaderField

        protected java.lang.String createCacheControlHeaderField​(CacheControl cacheAnnotation)