Module bus.http

Class CacheStrategy

java.lang.Object
org.miaixz.bus.http.cache.CacheStrategy

public class CacheStrategy extends Object
Given a request and a cached response, this class determines whether to use the network, the cache, or both. Selecting a cache strategy may add conditions to the request (like the "If-Modified-Since" header for conditional GETs) or warnings to the cached response (if the cached data is potentially stale).
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • networkRequest

      public final Request networkRequest
      The request to send on the network, or null if the network is not used.
    • cacheResponse

      public final Response cacheResponse
      The cached response to return or validate; null if this call does not use the cache.
  • Method Details

    • isCacheable

      public static boolean isCacheable(Response response, Request request)
      Returns true if response can be stored to later serve another request.
      Parameters:
      response - The response to check.
      request - The request that resulted in the response.
      Returns:
      true if the response is cacheable.