Class ClientCacheControl

java.lang.Object
com.linecorp.armeria.common.CacheControl
com.linecorp.armeria.common.ClientCacheControl

public final class ClientCacheControl extends CacheControl
Directives for HTTP caching mechanisms in requests.
See Also:
  • Field Details

    • EMPTY

      public static final ClientCacheControl EMPTY
      An empty instance with all directives disabled.
    • FORCE_NETWORK

      public static final ClientCacheControl FORCE_NETWORK
      "no-cache".
    • FORCE_CACHE

      public static final ClientCacheControl FORCE_CACHE
      "only-if-cached, max-stale=2147483647".
  • Method Details

    • parse

      public static ClientCacheControl parse(String... directives)
      Parses the specified "cache-control" header values into a ClientCacheControl. Note that any unknown directives will be ignored.
      Returns:
      the ClientCacheControl decoded from the specified header values.
    • parse

      public static ClientCacheControl parse(Iterable<String> directives)
      Parses the specified "cache-control" header values into a ClientCacheControl. Note that any unknown directives will be ignored.
      Returns:
      the ClientCacheControl decoded from the specified header values.
    • builder

      public static ClientCacheControlBuilder builder()
      Returns a newly created ClientCacheControlBuilder with all directives disabled initially.
    • isEmpty

      public boolean isEmpty()
      Description copied from class: CacheControl
      Returns true if all directives are disabled.
      Overrides:
      isEmpty in class CacheControl
    • onlyIfCached

      public boolean onlyIfCached()
      Returns whether the "only-if-cached" directive is enabled.
    • hasMaxStale

      public boolean hasMaxStale()
      Returns whether the "max-stale" directive is enabled.
      See Also:
    • maxStaleSeconds

      public long maxStaleSeconds()
      Returns the value of the "max-stale" directive or -1 if disabled or the value is not specified.
      See Also:
    • minFreshSeconds

      public long minFreshSeconds()
      Returns the value of the "min-fresh" directive or -1 if disabled.
    • staleWhileRevalidateSeconds

      public long staleWhileRevalidateSeconds()
      Returns the value of the "stale-while-revalidate" directive or -1 if disabled.
    • staleIfErrorSeconds

      public long staleIfErrorSeconds()
      Returns the value of the "stale-if-error" directive or -1 if disabled.
    • toBuilder

      public ClientCacheControlBuilder toBuilder()
      Returns a newly created ClientCacheControlBuilder which has the same initial directives with this ClientCacheControl.
      Specified by:
      toBuilder in class CacheControl
    • asHeaderValue

      public String asHeaderValue()
      Description copied from class: CacheControl
      Encodes the directives in this CacheControl into an HTTP "cache-control" header value.
      Specified by:
      asHeaderValue in class CacheControl
      Returns:
      the "cache-control" header value, or an empty string if no directives were enabled.
    • equals

      public boolean equals(@Nullable @Nullable Object o)
      Overrides:
      equals in class CacheControl
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class CacheControl