Class CacheStrategy


  • public final class CacheStrategy
    extends Object
    Given a request and cached response, this figures out 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).

    • Field Detail

      • networkRequest

        public final Request networkRequest
        The request to send on the network, or null if this call doesn't use the network.
      • cacheResponse

        public final Response cacheResponse
        The cached response to return or validate; or null if this call doesn't use a cache.
    • Method Detail

      • isCacheable

        public static boolean isCacheable​(Response response,
                                          Request request)
        Returns true if response can be stored to later serve another request.