You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Arturo Bernal (Jira)" <ji...@apache.org> on 2023/03/11 17:45:00 UTC

[jira] [Commented] (HTTPCLIENT-1368) stale-if-error request cache directive should also apply to non-revalidatable cache entries

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17699247#comment-17699247 ] 

Arturo Bernal commented on HTTPCLIENT-1368:
-------------------------------------------

HI [~jonm] / [~olegk] 

 

I've been working on implementing the stale-if-error request cache directive as defined in RFC 5861 ([http://tools.ietf.org/html/rfc5861]) in the BasicHttpCache class. So far, I've made the following changes:
 * Added the private final CacheConfig cacheConfig and private final CacheValidityPolicy cacheValidityPolicy fields to the BasicHttpCache class.
 * Added the following code to the getCacheEntry method:

 
{code:java}
if (cacheConfig.isStaleIfErrorEnabled() && (cacheValidityPolicy.getStaleness(root, Instant.now()).compareTo(TimeValue.ZERO_MILLISECONDS) > 0)) { return root; }{code}
 
This will check if the staleIfError directive is enabled and if the root cache entry is stale. If both conditions are met, it will return the stale cache entry.
Additionally, I've also made a small change to the CacheConfig class to add a setter method for the staleIfErrorEnabled field.

 
{code:java}
public Builder setStaleIfErrorEnabled(final boolean enabled) {
    this.staleIfErrorEnabled = enabled;
    return this;
}{code}
With these changes, we should now be able to properly implement the stale-if-error request cache directive as defined in RFC 5861.

However, I'm not entirely sure if I'm going in the right direction with this, so I would appreciate it if someone could take a look and provide some feedback.

> stale-if-error request cache directive should also apply to non-revalidatable cache entries
> -------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1368
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1368
>             Project: HttpComponents HttpClient
>          Issue Type: Improvement
>          Components: HttpCache
>    Affects Versions: 4.2.4, 4.2.5, 4.3 Beta1
>            Reporter: Jonathan Moore
>            Priority: Minor
>              Labels: stuck, volunteers-wanted
>             Fix For: Stuck
>
>
> The stale-if-error request cache directive is defined in RFC 5861:
> http://tools.ietf.org/html/rfc5861
> As implemented, this will only apply to cache entries that are revalidatable (i.e. they have an Etag or Last-Modified header and can be refreshed with a conditional request) but it should also apply to any stale cache entry.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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