Closed PiotrTecza closed 3 years ago
Thanks @PiotrTecza is this something you see in a real-life situation? If so is the API you are testing against is public? If so I would like to use it for such cases. Age header is rarely sent back as far as I have seen hence did not implement it.
Unfortunately, this is one of our internal APIs in JustEat. I have created a GitHub repo with the default Asp.Net Core WebAPI project and added ResponseCache middleware. Behaviour is exactly the same, every cached response is served with the Age header. Tested with System.Net.Http.HttpClient
and Postman v7.36.1 (please make sure Send no-cache header is disabled in settings)
Sure, that is fine. Of course, this is part of the spec just not implemented. I will try to get this working soon - before next week.
Amazing, thanks a lot @aliostad
OK I found a resource
https://fonts.gstatic.com/s/muli/v22/7Aulp_0qiz-aVz7u3PJLcUMYOFnOkEk30e6fwniDtzM.woff
This should be working now with version 2.8. Let me know if there is any issue.
Hi @aliostad, I believe it still does not work as expected. I had a quick look at the implementation and I think the problem is that there's no logic in ResponseValidator
delegate that would take Age header into account when calculating if a cache entry is Stale or not. So for the example above, it still keeps the entry in the cache for 60 sec, reporting that cache is OK
, and then it returns MustRevalidate
result.
Sure, I see that I need some behavioural tests now. I will work on it soon.
Hi, this should have been fixed now.
I can confirm this is now working as expected, thanks @aliostad.
Awesome! Thanks for using and improving it.
Great library @aliostad . I'm using it for client-side caching in conjunction with
Microsoft.AspNetCore.Mvc.ResponseCacheAttribute
for server-side caching. I've noticed that it doesn't honor the Age header when deciding if a cache entry is Stale.Example: Server response comes with the following headers: Cache-Control: public,max-age=60 Age: 59
With the current logic, the above response will be client cached for the next 60 sec even though this cache entry will be invalidated by the server in 1 second. Is it on purpose or could the logic be updated to honor the Age header?