缓存URL的内容 [英] Caching content of URL
问题描述
我有一个非常简单的用例:当远程端的内容发生更改(例如,上次修改"时更改)时,通过正确且自动的重新加载来缓存URL的内容.
I have a pretty simple use case: Cache the content of a URL with correct and automatic reloading when the content on the remote side changes (for example when "last modified" changes).
我该如何用Java做到这一点?
How can I do that in Java?
注意:我在类路径上有spring,guava和commons-lang3,但是我找不到对此的任何支持.Guava支持缓存逐出,但是无法实现每次访问检查.
Note: I have spring, guava and commons-lang3 on the classpath but I couldn't find any support for this. Guava supports cache eviction but there is no way to implement per-access checks.
推荐答案
您可以使用 HttpClient缓存.
HttpClient缓存提供了一个与HTTP/1.1兼容的缓存层,可与HttpClient一起使用-Java等效于浏览器缓存.
HttpClient Cache provides an HTTP/1.1-compliant caching layer to be used with HttpClient--the Java equivalent of a browser cache.
这篇关于缓存URL的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!