[
https://issues.apache.org/jira/browse/HTTPCLIENT-1725?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15172242#comment-15172242
]
Jon Moore commented on HTTPCLIENT-1725:
---------------------------------------
This is because of Section 13.9 of RFC 2616:
https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.9
"We note one exception to this rule: since some applications have traditionally
used GETs and HEADs with query URLs (those containing a '?' in the rel_path
part) to perform operations with significant side effects, caches MUST NOT
treat responses to such URIs as fresh unless the server provides an explicit
expiration time."
However, we also have this note from Section 4.2.2 of RFC 7234:
"Note: Section 13.9 of [RFC2616] prohibited caches from calculating heuristic
freshness for URIs with query components (i.e., those containing '?'). In
practice, this has not been widely implemented. Therefore, origin servers are
encouraged to send explicit directives (e.g., Cache-Control: no-cache) if they
wish to preclude caching."
So my opinion here is that the current module is doing the semantically safe
thing and not caching these; however, the note in the updated RFC 7234 would
seem to indicate that it would be ok to introduce a configuration option that
relaxed this rule.
[~chalford]: would you be interested in generating a patch to this effect?
> Heuristic caching does not work for URIs with a query string
> ------------------------------------------------------------
>
> Key: HTTPCLIENT-1725
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1725
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpCache
> Affects Versions: 4.5.1
> Reporter: Charlie Halford
>
> When enabling heuristic caching and setting a default lifetime, the responses
> from the server I am requesting from are not being stored in the cache.
> In org.apache.http.impl.client.cache.ResponseCachingPolicy, line 250
> determines if the URI contains a query string:
> {code}
> request.getRequestLine().getUri().contains("?")
> {code}
> A few lines below, it then checks to see if the response contains cache
> headers:
> {code}
> else if (!isExplicitlyCacheable(response))
> {code}
> As I am attempting to cache a response that I know does not contain cache
> headers, the response should succeed in being cached. However, it fails the
> isExplictlyCachable() check, and thus returns false to the overall
> isResponseCachable() method. The isExplicitlyCachable() method is checked
> later on in the stack, so perhaps it can be safely removed here?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]