Package com.squareup.okhttp
Interface OkResponseCache
- All Known Implementing Classes:
OkResponseCacheAdapter
public interface OkResponseCache
An extended response cache API. Unlike
ResponseCache, this
interface supports conditional caching and statistics.
Warning: Experimental OkHttp 2.0 API
This class is in beta. APIs are subject to change!-
Method Summary
Modifier and Type Method Description CacheResponseget(URI uri, String requestMethod, Map<String,List<String>> requestHeaders)voidmaybeRemove(String requestMethod, URI uri)Remove any cache entries for the supplieduriif the request method invalidates.CacheRequestput(URI uri, URLConnection urlConnection)voidtrackConditionalCacheHit()Track an conditional GET that was satisfied by this cache.voidtrackResponse(ResponseSource source)Track an HTTP response being satisfied bysource.voidupdate(CacheResponse conditionalCacheHit, HttpURLConnection connection)Handles a conditional request hit by updating the stored cache response with the headers fromhttpConnection.
-
Method Details
-
get
CacheResponse get(URI uri, String requestMethod, Map<String,List<String>> requestHeaders) throws IOException- Throws:
IOException
-
put
- Throws:
IOException
-
maybeRemove
Remove any cache entries for the supplieduriif the request method invalidates.- Throws:
IOException
-
update
Handles a conditional request hit by updating the stored cache response with the headers fromhttpConnection. The cached response body is not updated. If the stored response has changed sinceconditionalCacheHitwas returned, this does nothing.- Throws:
IOException
-
trackConditionalCacheHit
void trackConditionalCacheHit()Track an conditional GET that was satisfied by this cache. -
trackResponse
Track an HTTP response being satisfied bysource.
-