Class ResponseCacheControl


  • public final class ResponseCacheControl
    extends Object
    Indicates whether a response can be cached and under what conditions.
    • Method Detail

      • forMaxAgeSeconds

        public static ResponseCacheControl forMaxAgeSeconds​(long maxAge)
        Returns a cache control that will allow caching until the given maximum age (in seconds).
        Parameters:
        maxAge - the maximum age that the response can be cached for (in seconds).
        Returns:
        the cache control.
      • forMaxAge

        public static ResponseCacheControl forMaxAge​(Duration maxAge)
        Returns a cache control that will allow caching until the given maximum age.
        Parameters:
        maxAge - the maximum age that the response can be cached for.
        Returns:
        the cache control.
      • until

        public static ResponseCacheControl until​(Temporal deadline,
                                                 Clock clock)
        Returns a cache control that will allow caching until the given deadline according to the given clock.
        Parameters:
        deadline - the deadline at which to consider the response to be stale.
        clock - the clock to use to determine the time until the deadline.
        Returns:
        the cache control.
      • disableCaching

        public static ResponseCacheControl disableCaching()
        Indicates that clients and proxies should never cache the response under any circumstances.
        Returns:
        a cache control that disables caching.
      • isCacheable

        public boolean isCacheable()
        Indicates whether the response should ever be cached.
        Returns:
        true if the response can be cached or false to disable all caching.
      • getMaxAgeSeconds

        public long getMaxAgeSeconds()
        The maximum age (in seconds) that the response should be cached. After this time has expired the client or proxy should re-fetch the resource from the server.
        Returns:
        the maximum length of time in seconds to cache a response for.