hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michajlo Matijkiw (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HTTPCLIENT-990) Allow heuristic freshness caching
Date Tue, 19 Oct 2010 15:20:28 GMT

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-990?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Michajlo Matijkiw updated HTTPCLIENT-990:

    Attachment: heuristic_freshness.patch

This patch adds support for calculating freshness heuristically in the absence of the proper
headers.  It is configurable through CacheConfig, and is disabled by default.  If heuristic
freshness caching is enabled than the least restrictive of CacheValidityStrategy#isResponseFresh()
and CacheValidityStrategy#isResponseHeuristicallyFresh() is used to determine suitability.

This patch is submitted with the permission of my employer.

Thank you,

> Allow heuristic freshness caching
> ---------------------------------
>                 Key: HTTPCLIENT-990
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-990
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: Cache
>    Affects Versions: 4.1 Alpha2
>            Reporter: Vianney Carel
>            Priority: Minor
>             Fix For: 4.1.0
>         Attachments: debug.log, heuristic_freshness.patch
> I noticed that the CachingHttpClient behaves strangely when it receives responses with
only the public cache-control directive, e.g.:
> HTTP/1.0 200 OK
> Server: My test server
> Cache-control: public
> Content-Length: 1
> 1
> Using a debugger, I could see that the response is cached. But when the response is queried
from the cache, it is not considered as "fresh".
> According to the HTTP RFC, such responses "may" be cached (I understand it as a "should"
in our case)... but there's no reason to put responses in the cache if we don't use them later
> The "freshness of the response is analysed after the response is queried from the cache,
thanks to:
> CachedResponseSuitabilityChecker#canCachedResponseBeUsed()
> ... calling CacheEntry#isResponseFresh()
> ... returning true if the response date (getCurrentAgeSecs()) is lower than its use-by
date (getFreshnessLifetimeSecs())
> The issue is that getFreshnessLifetimeSecs() returns 0 when there is no max-age directive.
> This could be fixed by replacing the code of CacheEntry#isResponseFresh() by:
>     public boolean isResponseFresh() {
>         final long freshnessLifetime = getFreshnessLifetimeSecs();
>         if (freshnessLifetime == 0) {
>             return true;
>         }
>         return (getCurrentAgeSecs() < getFreshnessLifetimeSecs());
>     }
> But i'm not 100% confident about not producing some bad side-effects...

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

View raw message