// Uses Apache SystemDefaultHttpClient rather than
// DefaultHttpClient, thus the normal proxy settings for the
// JVM
// will be used
final DefaultHttpClient client = new SystemDefaultHttpClient();
// Support compressed data
// http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238
client.addRequestInterceptor(new RequestAcceptEncoding());
client.addResponseInterceptor(new ResponseContentEncoding());
final CacheConfig cacheConfig = new CacheConfig();
cacheConfig.setMaxObjectSize(1024 * 128); // 128 kB
cacheConfig.setMaxCacheEntries(1000);
// and allow caching
httpClient = new CachingHttpClient(client, cacheConfig);