![]() |
VOOZH | about |
ResponseCache in java is used for constructing implementation of URLConnection caches, and it nominates which resource has to be cached and up to what time duration a resource needed to be cached.
An instance of ResponseCache can be created using the system by doing :
ResponseCache.setDefault(ResponseCache)
The instance created by using the above statement will call an object of ResponseCache in order to :
java.net.ResponseCache
Methods of ResponseCache class :
| Method | Description |
|---|---|
| get(URI uri, String rqstMethod, Map<String,List<String> > rqstHeaders) | This method is used for retrieving the cached response depending upon the requesting URI, request method and request headers. |
| getDefault() | This method is used for retrieving the system-wide cache response. |
| put(URI uri, URLConnection conn) | The protocol handler calls this method whenever a resource has been retrieved and the ResponseCache must decide whether to store the resource in its cache. |
| setDefault(ResponseCache responseCache) | This method is used to set or unset the system-wide cache |
Applications of ResponseCache class :
1. In the java.net package, ResponseCache is used for implementing for caching of resources for various network applications such as :
java.net.ResponseCache
2. In java.net, ResponseCache is applied in fetching out system-wide response cache.
public static ResponseCache.getDefault()
3. In java.net, ResponseCcahe is used in setting or unsetting out the system-wide cache.
public static void ResponseCache.setDefault(ResponseCache responseCache)
Java program for implementing java.net.ResponseCache :
Output :
👁 Image