Interface ContentCachingService

All Known Implementing Classes:
JCacheContentCachingService

public interface ContentCachingService
Service that supports caching HTTP responses using keys derived from HTTP requests.
Since:
1.16
  • Field Details

  • Method Details

    • keyForRequest

      String keyForRequest(jakarta.servlet.http.HttpServletRequest request)
      Get a cache key from a HTTP request.
      Parameters:
      request - the HTTP request to derive a key from
      Returns:
      the key, or null if the request should not be cached
    • sendCachedResponse

      CachedContent sendCachedResponse(String key, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException
      Send a cached response for a given cache key, if possible.
      Parameters:
      key - the cache key, returned previously from keyForRequest(HttpServletRequest)
      request - the active HTTP request
      response - the active HTTP response to send the cached data to
      Returns:
      the cached content if the response was successfully handled, null otherwise (for example a cache miss)
      Throws:
      IOException - if any IO error occurs
    • cacheResponse

      default void cacheResponse(String key, jakarta.servlet.http.HttpServletRequest request, int statusCode, org.springframework.http.HttpHeaders headers, InputStream content) throws IOException
      Cache a response after completing an intercepted response.
      Parameters:
      key - the cache key, returned previously from keyForRequest(HttpServletRequest)
      request - the active HTTP request
      statusCode - the resolved HTTP response status code
      headers - the resolved HTTP response headers
      content - the resolved HTTP response content, or null if none
      compression - if content has been compressed then the compression type, otherwise null
      Throws:
      IOException - if any IO error occurs
    • cacheResponse

      void cacheResponse(String key, jakarta.servlet.http.HttpServletRequest request, int statusCode, org.springframework.http.HttpHeaders headers, InputStream content, ContentCachingService.CompressionType compression) throws IOException
      Cache a response after completing an intercepted response.
      Parameters:
      key - the cache key, returned previously from keyForRequest(HttpServletRequest)
      request - the active HTTP request
      statusCode - the resolved HTTP response status code
      headers - the resolved HTTP response headers
      content - the resolved HTTP response content, or null if none
      compression - if content has been compressed then the compression type, otherwise null
      Throws:
      IOException - if any IO error occurs
      Since:
      1.1