All Projects → kevinsawicki → etag-cache

kevinsawicki / etag-cache

Licence: other
HTTP requests backed by an ETag cache

Programming Languages

java
68154 projects - #9 most used programming language

etag-cache Build Status

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>

License

Examples

Making a request using a 10 MB cache

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");

Dependencies

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].