You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GET some url, returns a cacheable (for couple seconds) result with proper headers
GET same url within cached timeframe, does not hit the server, returns response directly from cache (great)
GET same url when cache has expire, sends the request to server, server respond with a 304no-cache.
Middleware trace is valid, store, meaning it re-stored the original response back into cache store (great)
GET same url within cached timeframe, should not hit the server but it actually re-validate the response.
Why is that? Since the last validate, the server respond with a 304 and the gem re-stored the response into the cache store. It should be able to pickup the cached response directly, at least while the cache entry is still fresh.
I think the issue is that when the gem ask if the entry is fresh here it's based on the max-age which is nil since it was a 304 with no-cache.
But correct me if I'm wrong, the no-cache statement is just for the 304 request, because you don't want to cache a 304 since it has empty body, but it does not mean you should not re-store the original response right?
Hope what I wrote is understandable..
Thanks!
The text was updated successfully, but these errors were encountered:
Hey @gottfrois given your steps, sounds like the re-stored response is keeping an outdated Date header, and so the cache is re-validated when it should it. Does your server returns the Date header on the 304 response?
In our API we return status code 304 for a cached resource but faraday-http-cache says it is uncacheable because it's not in the CACHEABLE_STATUS_CODES:
I have the following scenario:
GET
some url, returns a cacheable (for couple seconds) result with proper headersGET
same url within cached timeframe, does not hit the server, returns response directly from cache (great)GET
same url when cache has expire, sends the request to server, server respond with a304
no-cache
.valid, store
, meaning it re-stored the original response back into cache store (great)GET
same url within cached timeframe, should not hit the server but it actually re-validate the response.Why is that? Since the last
validate
, the server respond with a304
and the gem re-stored the response into the cache store. It should be able to pickup the cached response directly, at least while the cache entry is still fresh.I think the issue is that when the gem ask if the entry is fresh here it's based on the
max-age
which isnil
since it was a304
withno-cache
.But correct me if I'm wrong, the
no-cache
statement is just for the304
request, because you don't want to cache a304
since it has empty body, but it does not mean you should not re-store the original response right?Hope what I wrote is understandable..
Thanks!
The text was updated successfully, but these errors were encountered: