Caching content of URL

2019-07-02 07:02发布

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).

How can I do that in Java?

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.

标签: java url caching
2条回答
老娘就宠你
2楼-- · 2019-07-02 07:22

You may use HttpClient Cache.

HttpClient Cache provides an HTTP/1.1-compliant caching layer to be used with HttpClient--the Java equivalent of a browser cache.

查看更多
成全新的幸福
3楼-- · 2019-07-02 07:32

You could save the checksums of the files in database and compare it with the remote side file.

If it fails reload the file.

查看更多
登录 后发表回答