Open nurhat opened 5 years ago
@nurhat is this happening with 4xx and 5xx requests? Success isn't 200 only.
If so, it sounds like a bug to me -- @TomPallister is there something I'm missing as to why non-success would still be cached?
@philproctor yes, if you check OutputCacheMiddleware.cs line 55, it does not check http status code. Caching only disabled when http request fails with exception.
Got it -- I'll keep this open as a bug.
I think this was intentional and i wouldn't call it a bug. Why, for example, wouldn't you cache a 404 response if the api behind is telling you that the resource doesn't exist?
404 is a response type that might make sense to cache, but there's also a lot of other 4xx and 5xx responses that don't make sense to cache. Pretty much anything in the 5xx series shouldn't be cached, and some 4xx responses may be made due to current state of the services or similar.
Perhaps if response is not .IsSuccessStatusCode(), we should check against a configured whitelist of cacheable responses.
Yep, it was just an example. You mean configured by the user?
That's my thought, as part of the cache config.
mmmm, i don't like that. What if someone wants to disable one code for a downstream but not for another?
I was thinking about the ReRoute cache config, not the global. Maybe something like:
"FileCacheOptions": {
"TtlSeconds": 0,
"Region": "",
"StatusCodes": [400, 404, 405, 410]
},
Ohhhhhh that's better, but I think it's going to be kinda painful to declare all the routes explicitly. Maybe some global whitelist configuration with exceptions per route would be easier
I agree on the global + per route
@philproctor , any progress for the issue? thx
We're still having this problem with 500 responses being cached. Any chance a config was added and this issue just got buried?
Hi, An endpoint with caching enabled caches output even if downstream request returns anything other than httpstatus code with 200. Is it by design, or a bug?