Module bus.http

Class CacheControl.Builder

java.lang.Object
org.miaixz.bus.http.cache.CacheControl.Builder
Enclosing class:
CacheControl

public static final class CacheControl.Builder extends Object
A builder for creating Cache-Control request headers.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • noCache

      public CacheControl.Builder noCache()
      Do not accept a cached response without validation.
      Returns:
      this builder.
    • noStore

      public CacheControl.Builder noStore()
      Do not store the server's response in any cache.
      Returns:
      this builder.
    • maxAge

      public CacheControl.Builder maxAge(int maxAge, TimeUnit timeUnit)
      Sets the maximum age of a cached response. If the cached response is older than maxAge, it will not be used and a network request will be made.
      Parameters:
      maxAge - a non-negative integer. It is stored and transmitted with TimeUnit.SECONDS precision; finer precision will be lost.
      timeUnit - the unit of maxAge.
      Returns:
      this builder.
    • maxStale

      public CacheControl.Builder maxStale(int maxStale, TimeUnit timeUnit)
      Accept cached responses that have exceeded their freshness lifetime by at most maxStale. If unspecified, stale cached responses will not be used.
      Parameters:
      maxStale - a non-negative integer. It is stored and transmitted with TimeUnit.SECONDS precision; finer precision will be lost.
      timeUnit - the unit of maxStale.
      Returns:
      this builder.
    • minFresh

      public CacheControl.Builder minFresh(int minFresh, TimeUnit timeUnit)
      Sets the minimum number of seconds that a response will continue to be fresh for. If the response will be stale by the time it is received, a network request will be made.
      Parameters:
      minFresh - a non-negative integer. It is stored and transmitted with TimeUnit.SECONDS precision; finer precision will be lost.
      timeUnit - the unit of minFresh.
      Returns:
      this builder.
    • onlyIfCached

      public CacheControl.Builder onlyIfCached()
      Only accept the response from the cache.
      Returns:
      this builder.
    • noTransform

      public CacheControl.Builder noTransform()
      Do not accept a transformed response.
      Returns:
      this builder.
    • immutable

      public CacheControl.Builder immutable()
      Indicates that the response will not be updated while it's fresh.
      Returns:
      this builder.
    • build

      public CacheControl build()
      Builds a new CacheControl instance.
      Returns:
      a new CacheControl instance.