Class ServerCacheControl

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

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

    • EMPTY

      public static final ServerCacheControl EMPTY
      An empty instance with all directives disabled.
    • DISABLED

      public static final ServerCacheControl DISABLED
      "no-cache, no-store, must-revalidate".
    • REVALIDATED

      public static final ServerCacheControl REVALIDATED
      "no-cache, must-revalidate".
    • IMMUTABLE

      public static final ServerCacheControl IMMUTABLE
      "max-age=31536000, public, immutable".
  • Method Details

    • parse

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

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

      public static ServerCacheControlBuilder builder()
      Returns a newly created ServerCacheControlBuilder 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
    • cachePublic

      public boolean cachePublic()
      Returns whether the "public" directive is enabled.
    • cachePrivate

      public boolean cachePrivate()
      Returns whether the "private" directive is enabled.
    • immutable

      public boolean immutable()
      Returns whether the "immutable" directive is enabled.
    • mustRevalidate

      public boolean mustRevalidate()
      Returns whether the "must-revalidate" directive is enabled.
    • proxyRevalidate

      public boolean proxyRevalidate()
      Returns whether the "proxy-revalidate" directive is enabled.
    • sMaxAgeSeconds

      public long sMaxAgeSeconds()
      Returns the value of the "s-maxage" directive or -1 if disabled.
    • toBuilder

      public ServerCacheControlBuilder toBuilder()
      Returns a newly created ServerCacheControlBuilder which has the same initial directives with this ServerCacheControl.
      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