MichaCo / CacheManager

CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
http://cachemanager.michaco.net
Apache License 2.0
2.35k stars 456 forks source link

Ocelot Cache - How do we Cache only success(200) response from micro services via API Gateway #353

Open chitharansivasamy opened 3 years ago

chitharansivasamy commented 3 years ago

The problem is we had used the below Ocelot JSON to cache the response and it's holding the data for one full day (86400 secs). here is suppose to get some errors during the services call like(500,502,499...). what happened is the cached error response was not even updated till one full day even the services issue got resolved.

"UpstreamPathTemplate": "/Products/GetProductMetaData",
"UpstreamhttpsMethod": [ "GET" ],
"FileCacheOptions": { "TtlSeconds": 86400 },

So we are looking for the gateway to cache only success and not the failure cases. It should be hit services till when its bring success(200). Is there any option in OCELOT to restrict caching based on the HTTP Status code like 500, 502, 503, 499..etc?

MichaCo commented 3 years ago

You'd have to post/ask that in the Ocelot repository I think. I have no idea ;)