HTTP requests backed by an ETag cache
Library to make transparent HTTP requests that can be served locally when
the server replies with a 304 Not Modified
response for a If-None-Match
header set by the client.
The library is available from Maven Central:
<dependency>
<groupId>com.github.kevinsawicki</groupId>
<artifactId>etag-cache</artifactId>
<version>0.6</version>
</dependency>
File file = new File("/tmp/http-cache");
EtagCache cache = EtagCache.create(file, TEN_MB);
CacheRequest request = CacheRequest.get("http://google.com", cache);
System.out.println("Response was " + request.body());
if (request.cached())
System.out.println("Cache hit");
else
System.out.println("Cache miss");