Skip to content

Most visited

Recently visited

navigation
Added in API level 1

ResponseCache

public abstract class ResponseCache
extends Object

java.lang.Object
   ↳ java.net.ResponseCache
Known Direct Subclasses


Caches URLConnection responses.

The system's default cache can be set using setDefault(ResponseCache). If getUseCaches() returns true, URLConnection will use the default response cache, if one has been set.

Although URLConnection will always call put(URI, URLConnection), the specific ResponseCache implementation gets to decide what will actually be cached, and for how long.

Summary

Public constructors

ResponseCache()

Public methods

abstract CacheResponse get(URI uri, String requestMethod, Map<StringList<String>> requestHeaders)

Returns the cached response corresponding to the given request.

static ResponseCache getDefault()

Returns the system's default response cache, or null.

abstract CacheRequest put(URI uri, URLConnection connection)

Allows the protocol handler to cache data after retrieving resources.

static void setDefault(ResponseCache responseCache)

Sets the system's default response cache.

Inherited methods

From class java.lang.Object

Public constructors

ResponseCache

Added in API level 1
ResponseCache ()

Public methods

get

Added in API level 1
CacheResponse get (URI uri, 
                String requestMethod, 
                Map<StringList<String>> requestHeaders)

Returns the cached response corresponding to the given request.

Parameters
uri URI: the request URI.
requestMethod String: the request method.
requestHeaders Map: a map of request headers.
Returns
CacheResponse the CacheResponse object if the request is available in the cache or null otherwise.
Throws
IOException if an I/O error occurs while getting the cached data.
IllegalArgumentException if any one of the parameters is set to null.

getDefault

Added in API level 1
ResponseCache getDefault ()

Returns the system's default response cache, or null.

Returns
ResponseCache

put

Added in API level 1
CacheRequest put (URI uri, 
                URLConnection connection)

Allows the protocol handler to cache data after retrieving resources. The ResponseCache decides whether the resource data should be cached or not. If so, this method returns a CacheRequest to write the resource data to. Otherwise, this method returns null.

Parameters
uri URI: the reference to the requested resource.
connection URLConnection: the connection to fetch the response.
Returns
CacheRequest a CacheRequest object with a WriteableByteChannel if the resource has to be cached, null otherwise.
Throws
IOException if an I/O error occurs while adding the resource.
IllegalArgumentException if any one of the parameters is set to null.

setDefault

Added in API level 1
void setDefault (ResponseCache responseCache)

Sets the system's default response cache. Use null to remove the response cache.

Parameters
responseCache ResponseCache
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.